Deliverability

fsockopen Error 111 "Connection refused" on Mandrill port 587

Error 111 means your server tried to open smtp.mandrillapp.com:587 and the connection was refused before SMTP began, so your Mandrill credentials were never checked. Usually a firewall or host blocks outbound SMTP. Test the port from the server, then open egress or switch to port 2525 or 465.

Sohail HussainSohail Hussain9 min read

Short answer

  • Error 111 means your server's own connection to smtp.mandrillapp.com on port 587 was refused before Mandrill saw any login, so the cause is the network path (an outbound firewall rule or a host that blocks SMTP), not your API key.
  • Run a port test from the web server itself. If 2525 or 465 connects, change the SMTP port in your app. If every port fails, open outbound rules or ask your host to allow them.

You are probably looking at this message in a PHP app, often PrestaShop or WordPress:

The SMTP connection failed to start [smtp.mandrillapp.com:587]: fsockopen returned Error Number 111 and Error String 'Connection refused'

Mail stopped, and rechecking the username and API key changed nothing. That is expected, because the connection never got far enough for Mandrill to check credentials.

Why it happens

fsockopen is the PHP function that opens a raw network socket. Error 111 is the Linux errno ECONNREFUSED: the other end, or something in between, answered the connection attempt with an immediate reset. The error text comes from the mail library inside your app; the same code can show up in any PHP software that sends mail this way. The only source for this exact wording is an old PrestaShop forum thread from 2017, so treat its specifics with care. The network diagnosis below does not depend on it.

Causes, most common first:

  1. Your host blocks outbound SMTP. Many shared hosts, VPS providers and cloud platforms restrict outbound mail ports to fight spam. Some block only port 25; others also block 587.
  2. A firewall rule on your own server rejects the traffic. iptables, ufw, nftables, CSF or a cloud security group with a default-deny egress policy.
  3. Your network filters port 587 specifically. A different port may pass.
  4. The destination is wrong. A typo in the hostname, a stale hosts-file entry or a proxy that rewrites DNS sends your connection to something that is not Mandrill's SMTP server. A refusal is what that looks like.
  5. Intermittent resource limits. Exhausted file descriptors or connection-rate limits can produce sporadic 111s.

I can't tell from the error alone which one you have. The tests below separate them in a couple of minutes.

What you seeWhat it usually means
Error 111, "Connection refused"An immediate reset: a REJECT rule, a host-level block, or nothing listening at that address and port
Error 110, "Connection timed out"Packets silently dropped (a DROP rule or filtered network)
Error 13, "Permission denied"Local policy such as SELinux stopping PHP from opening sockets
SMTP 535 authentication failedYou reached Mandrill; the username or API key is wrong

Step 1: test the port from the server

Run these on the machine that runs your site, not on your laptop. A laptop on a different network proves nothing about your server.

# Does the name resolve to a public IP?
dig +short smtp.mandrillapp.com

# Which ports are reachable?
nc -vz -w 5 smtp.mandrillapp.com 587
nc -vz -w 5 smtp.mandrillapp.com 2525
nc -vz -w 5 smtp.mandrillapp.com 465

# STARTTLS handshake (587 or 2525)
openssl s_client -starttls smtp -connect smtp.mandrillapp.com:587

# Implicit TLS (465)
openssl s_client -connect smtp.mandrillapp.com:465

telnet smtp.mandrillapp.com 587 works if it is installed. A healthy STARTTLS connection prints a 220 greeting.

Read the result like this:

  1. 587 refused, 2525 connects: your network filters 587. Use 2525 (Step 2).
  2. 587 and 2525 refused, 465 connects: something interferes with STARTTLS or with those ports. Use 465.
  3. Everything refused while other outbound connections work: outbound SMTP is blocked. Go to Step 3 or 4.
  4. dig returns a private address (10.x, 192.168.x, 172.16 to 31.x) or nothing: fix DNS or the hosts file first.

SendGrid's support docs describe the same pattern for its own SMTP service: if 587 is blocked, 2525 is a common fallback. That is a different vendor, so confirm Mandrill's current ports in its own SMTP documentation before relying on this.

Step 2: switch the port in your app

This is the fastest fix on shared hosting, where you can't edit firewall rules.

In PrestaShop the settings live under Advanced Parameters > E-mail, though labels vary by version:

  1. Set the mail method to use your own SMTP server.
  2. Set the SMTP server to smtp.mandrillapp.com.
  3. Set the SMTP port to 2525 (STARTTLS) or 465 (implicit SSL).
  4. Set encryption to TLS for 2525 or 587, and SSL for 465.
  5. Save, then send a test email from that page.

Wrong encryption gives a different failure (a handshake error or a hang), not a refusal. If the error text changes after you edit the port, you have cleared the network problem and can move on to credentials. For help matching modes to ports, see our explainer on SSL/TLS for SMTP.

Match the mode to the port

Port 465 expects TLS from the first byte (SSL in most PHP mail settings). Ports 587 and 2525 start in plain text and upgrade with STARTTLS (TLS in most settings). Mixing them up causes handshake errors that look like a new problem.

Step 3: open outbound rules on your own server

If you manage the server, look for egress filtering.

sudo iptables -S OUTPUT
sudo ufw status verbose
sudo nft list ruleset

Look for a REJECT or DROP on outbound TCP 587, or a default-deny output policy, then add an allow rule for the port you need. Also check:

  • Cloud security groups and network ACLs that restrict outbound traffic. Hardened templates often do.
  • A control panel firewall such as CSF, where allowed outbound ports are listed under TCP_OUT.
  • Container or VPS network policies that limit egress.
  • A VPN, corporate proxy or DNS filter on the path, if you are testing from an office or home machine.

A refusal rather than a timeout often points at a rule that explicitly rejects, which tends to be a deliberate setting someone made. Look at who changed the firewall or hosting plan recently.

Step 4: ask your host

If all three ports fail and your own rules are clean, the block is upstream. Open a ticket, include the nc output and your server's IP, and ask which outbound SMTP ports are permitted. Some hosts lift the block on request. Others require you to use their own relay, in which case you either use it or move hosting.

Step 5: check the Mandrill side, but only after the port opens

A refused connection is not an account problem. Once nc reports success and your app reaches the SMTP greeting, the usual next errors are authentication ones.

  • Mandrill is now Mailchimp Transactional. Mailchimp's help says it is available as an add-on with the Standard plan or higher, so check that your account still has it active. See Mailchimp's page on adding or removing Transactional.
  • Confirm that the SMTP username and the API key you pasted are current. Transactional users must also authenticate their sending domain before sending to outside recipients, per Mailchimp's domain authentication guide.

If the port test works from another machine but not from your server, the problem is on your side of the network.

Intermittent 111 errors

If the error comes and goes, suspect a firewall that limits connection rates, a process running out of file descriptors, or a host that throttles outbound connections. Log timestamps and compare them with host-side events. Sending through a queue instead of inside the web request keeps the site responsive while you investigate.

Checklist before you try again

  • You ran the port tests on the web server, not your laptop.
  • dig returns a public IP for smtp.mandrillapp.com.
  • At least one of 587, 2525 or 465 connects.
  • The app's encryption setting matches the port (TLS for 587 and 2525, SSL for 465).
  • No outbound REJECT or DROP rule exists for the port.
  • Your Mandrill (Mailchimp Transactional) account is active and the credentials are current.

If nothing works

Contact your hosting provider first, since the block is almost always on their network. If the test connects but sending still fails, contact Mailchimp Transactional support. Send the exact error text, the failing port, the nc or openssl output, your server's public IP and the time of the failure (with time zone). A short message to copy:

Subject: Outbound SMTP to smtp.mandrillapp.com refused (errno 111)

My server {your-server-ip} gets "fsockopen returned Error Number 111 and
Error String 'Connection refused'" when connecting to
smtp.mandrillapp.com on port 587. Time of last failure: {date, time, timezone}.

nc -vz results from the server:
587: {result}
2525: {result}
465: {result}

Please confirm which outbound SMTP ports are allowed for my plan and
whether any firewall rule on your side is rejecting this traffic.

Preventing it

  • Rerun the nc tests after any hosting, firewall or OS change.
  • Note which port you chose so a later firewall edit doesn't break it.
  • Send transactional email through a queue so an unreachable relay doesn't block page loads.
  • Keep your SMTP settings in one documented place.

Common questions

Does Error 111 mean my Mandrill API key is wrong?

No. A wrong key gives an SMTP 535 authentication error, which can only happen after the connection succeeds. Error 111 happens before any login.

Why "refused" and not "timed out"?

A refusal means a reset came back right away, usually from a REJECT rule or a host policy. A timeout means packets vanished, which points to a DROP rule or a filtered network. Both are network-path problems.

Is port 2525 safe to use?

Yes, in the sense that it is a common alternative submission port and uses STARTTLS. It is not an official standard port, so confirm in Mandrill's documentation that it is currently offered before you rely on it.

Does this error only affect PrestaShop?

No. PrestaShop's mail library produced the message in the thread that ranks for it, but any PHP app that opens a socket with fsockopen can report the same code.

deliverabilitymandrillerror-codes
Share this article
Sohail Hussain

Sohail Hussain

Founder & CEO at Mailneo

Building Mailneo — AI-powered email marketing for growing businesses.

Related Articles

Deliverability

0x800ccc0e: Outlook Unable to Connect to SMTP Server, Fixed

Outlook error 0x800ccc0e means the app could not open a connection to your outgoing (SMTP) server. Usually the port, encryption setting or password is wrong, or antivirus, a firewall or your ISP is blocking it. Set port 587 with STARTTLS, turn on SMTP authentication, and test again.

Sohail Hussain|10 min read
Deliverability

SocketLabs "421 4.5.1 Too many errors" blacklist: how to fix it

`421 4.5.1 Too many errors, you have been temporarily blacklisted` means a SocketLabs server saw repeated auth or bad-address errors from your IP and paused it. Stop whatever is retrying, fix credentials and invalid recipients, clear the queue, and wait. The block usually lifts within minutes, but returns if retries resume.

Sohail Hussain|9 min read
Deliverability

421-4.7.0 Gmail Has Detected This Message Is Suspicious: Fix

The 421-4.7.0 "suspicious due to the nature of the content and/or the links" error means Gmail's content filter rejected your message after DATA, not an authentication check. Remove click tracking or move it to your own domain, drop URL shorteners, check link reputation, then retest with a plain message.

Sohail Hussain|10 min read
Deliverability

421 4.7.0 IP not in whitelist for RCPT domain: what it means

The error 421 4.7.0 IP not in whitelist for RCPT domain means the recipient's mail gateway, usually Mimecast in reports, only accepts connections from approved IPs, and the Google sending IP isn't on that list. The fix is on the recipient side: their admin must allow the IPs or change the mail routing.

Sohail Hussain|9 min read

Ready to supercharge your email marketing?

Start sending smarter emails with AI-powered campaigns. No credit card required.

Get Started Free