3-digit reply code

SMTP error 111

Connection refused — an OS socket error, not an SMTP code.

Updated Jul 1, 2026

The short answer

SMTP 111 is not an SMTP reply code. It is the POSIX socket error ECONNREFUSED ("connection refused"): the TCP connection to your mail server was rejected before the SMTP conversation could start. Fix the host and port, open outbound firewall rules on 25/465/587, and lift any host-level SMTP restrictions.

Quick fix

Correct the host and port, open outbound firewall rules on 25/465/587, and lift any host-level SMTP restrictions.

What it means

PHPMailer and Python's smtplib surface "111" straight from the operating system — it is not a server response. ECONNREFUSED happens at the network layer, before SMTP begins: your client never got to greet the server, log in, or name a recipient. That rules out a whole class of "explanations" — a bad recipient address, a wrong SMTP password, or the recipient blocking something cannot be the cause, because you never reached the point in the dialogue where any of those would matter.

Common causes

Wrong host or port

Pointing at a host with no SMTP listener, or a port the server is not on. Use 587 (STARTTLS) or 465 (implicit TLS) for submission; port 25 is server-to-server and widely blocked for clients.

Outbound firewall block

Many hosts and ISPs block outbound 25/465/587 by default to curb spam. Very common on shared and VPS hosting.

Host-level SMTP restrictions

cPanel/WHM's "SMTP Restrictions" forces port-25 traffic through the local mail server; a rule like CSF's SMTP_BLOCK can restrict 465/587. Check both.

Nothing listening

Pointing at localhost when no local mail server is running.

IPv6 vs IPv4

The hostname resolves to a filtered IPv6 address while IPv4 would work.

How to fix it

  1. Confirm host/port and test connectivity

    From the sending server, test the TCP path. A "connection refused" here is a network/port problem, not your mail code.

    openssl s_client -connect smtp.example.com:465
    openssl s_client -starttls smtp -connect smtp.example.com:587
    nc -vz smtp.example.com 587
  2. Open outbound firewall rules

    Allow egress on your submission port (usually 587 or 465). On your own server, permit outbound; on shared hosting, ask the host to confirm outbound SMTP is not blocked.

  3. Lift host SMTP restrictions

    On cPanel/WHM disable "SMTP Restrictions" (or the CSF SMTP_BLOCK rule), or add your sending user to the allow list.

  4. Match the port to the encryption mode

    Use 465 with implicit TLS or 587 with STARTTLS. Do not request STARTTLS on 465.

  5. Force IPv4 if IPv6 is filtered

    Resolve and connect to the IPv4 address to bypass a blocked AAAA record.

Common questions

Is 111 an actual SMTP status code?

No. SMTP replies are three-digit codes in RFC 5321. 111 is the OS errno ECONNREFUSED — a TCP error meaning the connection was refused before SMTP started.

PHPMailer says 111 but my credentials are right — why?

Credentials do not matter yet. 111 means the connection was refused before login; you never reached authentication. Look at host, port, and firewall.

Which port should I use?

587 with STARTTLS or 465 with implicit TLS. Avoid port 25 for client submission — it is widely blocked.

Related codes

Ready when you are

Most rejections come back to sender reputation.

Blocklists, auth failures, and policy blocks are what warmup prevents. Warm up your domain so your mail is trusted before you hit send.

7-day free trialNo credit cardCancel anytime