IMAP
IMAP Connection Refused is a TCP ECONNREFUSED error, not an IMAP protocol code. Learn why the server rejected the connection on port 143/993 and how to fix it.
Updated Jul 1, 2026
The short answer
"IMAP Connection Refused" is a TCP-layer error (ECONNREFUSED), not an IMAP protocol reply: the target host actively rejected the connection because nothing is listening on the IMAP port you tried (143 or 993), or a firewall sent a reset. Fix it by confirming the correct host and port, verifying the IMAP service is running and listening, and checking firewall/IP-block rules.
"Connection refused" is not an IMAP protocol response — IMAP servers reply with tagged OK, NO, or BAD lines, never "connection refused." It is a TCP/socket-layer error that happens before any IMAP conversation begins. At the operating-system level it surfaces as ECONNREFUSED (or "Connection refused"), and it means your client's SYN packet reached the host, but the host answered with a TCP RST (reset) instead of completing the handshake.
This is important because it tells you exactly where the problem is: the host is reachable, but nothing accepted the connection on the port you tried. That distinguishes it from two look-alike failures:
ETIMEDOUT) — no response at all, usually a wrong host, dropped packets, or a firewall silently discarding traffic.REJECT rule, security group, or ISP block returns an RST, which your client sees as "refused." (A DROP rule would instead cause a timeout.)127.0.0.1, or a reverse proxy / load balancer in front of it has no upstream.Work outward from the client to the server:
1. Confirm host and port. Use the documented values for your provider, and match the port to the encryption mode: 993 for SSL/TLS (implicit), 143 for STARTTLS/plaintext.
2. Test the raw TCP connection (this isolates the socket layer from IMAP/TLS):
# Plain reachability test — does the port accept a connection?nc -vz imap.example.com 993# Or with openssl for a 993 (implicit TLS) endpoint:openssl s_client -connect imap.example.com:993 -crlf
nc reporting "Connection refused" confirms the RST; "succeeded"/a TLS banner means the port is open and you should look at credentials or TLS instead.
3. On the server, verify the daemon is listening:
# Is something bound to 143/993 and on which interface?ss -tlnp | grep -E ':143|:993'systemctl status dovecot # or cyrus-imapd / courier-imap
If it's bound only to 127.0.0.1, change the listen address to the public/LAN interface and restart.
4. Check firewall and IP-block rules. Confirm 143/993 are allowed inbound (host firewall, cloud security group, ISP). Look for an IP ban from fail2ban or similar:
sudo fail2ban-client status dovecot
5. Read the logs on both sides — the mail server log (e.g. /var/log/mail.log) and your client's debug output — to confirm whether the refusal is a missing listener, a firewall reset, or an IP block.
With Courier
References
FAQ
No. IMAP responses are tagged OK/NO/BAD lines. "Connection refused" is a TCP/socket error (ECONNREFUSED) that occurs before any IMAP exchange — the host sent a TCP reset because nothing accepted the connection on that port.
One API, every provider
Courier connects to your email, SMS, and push providers, handles retries and failover, and surfaces delivery errors in plain language.
Reply-code definitions per RFC 8314 (TLS for email access); RFC 9051 (IMAP4rev2). Last reviewed Jul 1, 2026. Courier is not affiliated with third-party providers; error behavior may vary by implementation.
© 2026 Courier. All rights reserved.