Skip to content

IMAP "Too many connections" with Dovecot under load

How to diagnose Dovecot connection-limit errors on a cPanel server, distinguish abusive clients from legitimate heavy users, and adjust per-user and global limits without exhausting RAM.

A user calls about Apple Mail refusing to refresh because of “Too many connections from your IP address.” The reflex is to raise the limit; that solves nothing if the cause is a misbehaving client opening twenty connections per folder. The right move is to figure out why the limit hit, raise it only if the cause is legitimate, and configure clients that ignore standard behavior so the next user doesn’t trip the same wire.

What’s happening

Dovecot limits IMAP/POP3 connections at two levels: globally per host (via mail_max_userip_connections) and per user via the same setting scoped to a single account. The default is 10 per user per IP. A modern desktop client with multiple folders open, an iOS device, and a phone IMAP can comfortably hit 8–12 connections. Some clients (a misconfigured RoundCube instance, certain BlackBerry-era apps, or buggy IMAP libraries) open a new connection per request and never close — those eat the budget instantly.

How to verify

Check Dovecot’s current limits and live connection count:

doveconf | grep mail_max_userip_connections
doveadm who | head
doveadm who -1 | awk '{print $1}' | sort | uniq -c | sort -rn | head

The third command groups by user so you see who is over the limit. Then check the source IPs for that user:

doveadm who -1 user@example.com

If one IP shows 30 connections, that’s the abusive client; if 30 IPs each show 1, that’s a healthy user.

The fix

  1. For an abusive client, fix the client. Common culprits: Outlook with old shared mailboxes still configured, RoundCube without IDLE configured properly, custom IMAP scripts that don’t close connections. The fix is on the client side, not the server.

  2. For a legitimate heavy user (more than 10 devices, multiple folders open), raise their per-user limit by editing /etc/dovecot/dovecot.conf (cPanel allows overrides via /etc/dovecot/conf.d/) with:

    userdb {
      driver = static
      args = uid=mail gid=mail
      override_fields = mail_max_userip_connections=20
    }

    Or set globally if every heavy user needs it.

  3. Configure Dovecot to log connection events at debug level temporarily so you can see who’s connecting and from where: mail_debug = yes. Turn off after diagnosis — debug logging is heavy.

  4. Watch memory. Each Dovecot IMAP connection consumes a few MB of RAM. Raising the limit globally to 50 across 500 users could double Dovecot’s memory footprint. Tune imap_idle_notify_interval and mailbox_idle_check_interval to keep idle connections cheap.

  5. Document the legitimate exceptions. A user with 40 devices needs a note in their account record — when they call again about a limit, the next operator doesn’t reinvent the conversation.

For environments with persistently high IMAP concurrency, Stack Harbor tunes the Dovecot stack and the per-user overrides as part of cPanel/WHM management.