Audit and Remove Stale Dovecot Instances with doveadm

Use doveadm instance to see which Dovecot instances the host still remembers and to remove an obsolete entry. It earns its keep on a box running more than one Dovecot, and after a service move leaves stale state behind. The read-only audit takes about five minutes.

The installed package checked for this guide is dovecot-core 1:2.3.21+dfsg1-2ubuntu6.5, providing the Dovecot 2.3 command documented by the local manpage.

Warning: The listing is metadata. It is not, by itself, proof that a process is alive. Removal takes longer only if you need to prove the target is no longer used.

1. Check the command and your access

Run the version check and confirm the subcommand is available. This does not change Dovecot configuration or service state.

doveadm --version
doveadm help instance

On the reference installation, doveadm --version reports Dovecot 2.3.21. The manpage describes two operations: instance list and instance remove. If your distribution reports a different version, read its installed manpage before copying the examples below.

2. List the remembered instances

Start with the default table output. It shows the instance path, its configured or discovered name, when it was last used, and whether Dovecot currently considers it running.

doveadm instance list

A typical record looks like this:

path                         name    last used           running
/run/dovecot                 dovecot 2026-09-23 10:03:43 no

Checkpoint: Write down the full path and name you intend to investigate. The removal command accepts either the instance name or its base directory. The path is often safer when names are duplicated across old configurations, because it identifies the instance's base_dir directly.

These are ordinary, read-only checks. Replace the placeholder path with the path from your listing:

INSTANCE_BASE_DIR="/run/dovecot"
sudo systemctl status dovecot
sudo find "$INSTANCE_BASE_DIR" -maxdepth 1 -type f -printf '%f\n' 2>/dev/null

Tip: The sudo prefix is needed only where your account cannot inspect the service or directory. A missing directory alone does not prove the record is stale, because a service may recreate runtime directories during startup.

3. Choose output for scripts or people

The global -f option changes presentation without changing the query:

doveadm -f table instance list
doveadm -f tab instance list
doveadm -f flow instance list
doveadm -f pager instance list

The flow form is usually easiest to log because a record stays on one line:

path=/run/dovecot name=dovecot last used=2026-09-23 10:03:43 running=no

Tip: In scripts, treat field names and values as data rather than splitting blindly on spaces. The date contains a space, and names or paths differ between installations. The manpage documents these four formatters, not a JSON output mode.

4. Remove only a confirmed stale entry

Removal changes Dovecot's instance list. It does not edit dovecot.conf, stop a service, or uninstall a package. It is still a consequential administrative action, so pause first if the instance may be used by a director, proxy or backend.

Use the exact name from the listing:

sudo doveadm instance remove dovecot

Or use the exact base directory instead:

sudo doveadm instance remove /run/dovecot

Use one form, not both. The command takes name | base_dir.

Warning: Do not substitute a broad parent such as /run, and do not remove a record merely because it is not currently running.

Recovery: The local manpage does not describe an undo command. If you remove the wrong record, start the intended Dovecot instance again so it adds itself back to the list automatically, then verify its name and base directory. Restore any missing instance_name configuration separately if that was the actual mistake.

5. Verify the result

List the instances again and check that the targeted name or path is gone. If you removed an active record, confirm service health and mail flow before treating its reappearance as a fault.

doveadm instance list
doveadm -f flow instance list

Checkpoint: With no matching record, the cleanup is complete. If it comes straight back, inspect the service logs and configuration. Running Dovecot instances add themselves automatically, so a live instance will recreate its entry.

Common traps

Done means