If you are setting up your WordPress site with a SMTP plugin or using the PHPMailer library for sending email from your web server, you might encounter this SMTP Error: Failed to connect to server: Connection refused (111)/Network is unreachable (101). It’s a common connectivity issue on most shared hosting servers. In this post we will explain the issue in detail and show you how you can resolve it to have a fully functional email/SMTP setup.
SMTP connection requires a port such 25/465/587. Based on the type of connection you may also need to use encryption (e.g. SSL/TLS) or no encryption at all. SSL encryption is mainly used on port 465 where as TLS on port 587. On some shared hosts port 465/587 are blocked by default. This makes it so PHPMailer/SMTP plugin can’t even connect to the remote SMTP server. Sometimes those ports are open but they don’t support encryption. This causes the email to be sent without any encryption which can be a security issue. Your remote SMTP host can also decide which connection to accept. For example: If you try to make a non-encrypted connection to a SMTP host like Gmail (smtp.gmail.com) it will refuse since the connection is not secure. In that case the error may look similar to this,
- unable to connect to ssl://smtp.gmail.com:465 (connection refused)
- unable to connect to smtp.gmail.com:587 (connection refused)
Connection refused (111)/Network is unreachable (101) error can also occur if your web host simply doesn’t allow external SMTP connection. This issue is common on a GoDaddy server where they only allow their own SMTP configuration. If you contact them regarding this issue they will assure you that port 465 and 587 are open (when they are not). If you get back to them again they will tell you to use their SMTP server host instead of your own. So if you are on a GoDaddy server and having this issue your SMTP configuration should look like the following:
- SMTP Host/Server: relay-hosting.secureserver.net
- Port: 25
- SMTPAuth: false
This should allow you to send email from your web server without any interruption/error. If you come across a different solution for resolving this type of error feel free to share it in the comments.