Trouble with IMAP Connection refused error – Here’s how to fix it!

Trouble with imap connection

Table of Contents

Having a lot of trouble with my email account. It’s shows IMAP Connection refused error every time. What’s actually happening?

That was a recent support ticket received at our Dedicated Support Services department where we help server owners resolve critical errors on their servers.

Website owners usually receive this error due to IMAP configuration issues, firewall restrictions and more.

Today, we’ll see the top 4 reasons for this error and how we fix them.

IMAP connection refused – What this means?

IMAP connection refused error means that the IMAP server rejected the connection made by the email application. Users commonly see this error when they access their emails through any webmail clients such as Squirrelmail, Roundcube, etc.

And, they see the entire error message like this.

Error connecting to IMAP server: localhost.
111 : Connection refused


Here, our Support Experts check the server logs(/var/log/messages) and the email logs(/var/log/maillog or /usr/local/psa/var/log/maillog) to determine the source of the problem.


IMAP Connection refused – Causes and Fixes

Now, let’s discuss the top 4 reasons for this error and how our Support Experts rule out each possibility.

1) Service downtime

One of the main reasons for this error is IMAP service not running on the server. Common IMAP servers are Dovecot, Courier-IMAP, etc. IMAP service allows users to access the emails from anywhere. So, if the IMAP service crashes, the connection fails and result in IMAP connection refused errors.

How we fix?

Service downtime can occur due to traffic spikes, resource outages, spamming, DDoS attacks, disk errors, and so on. So, here our Support Engineers identify the reason and permanently fix it.

For example, if we there’s high load on the server, we first identify the resource that is being abused. Further, we identify the user abusing this resource and disable it.

Similarly, if we find any dead or non-responsive processes, we’ll kill those dead processes and restart the services. For example, on CentOS – cPanel servers, we restart the IMAP service using the below command.

service dovecot restart


Finally, we confirm that IMAP service is listening on the server using the netstat command.

netstat -plnt | grep :143


2) IMAP configuration issues

Similarly, configuration issues in the IMAP configuration file are another main reason for this error. Typo mistakes, syntax errors, incorrect parameters in the IMAP configuration can create errors. For example, users commonly see this error while restarting Dovecot service on the server.

Starting Dovecot Imap: doveconf: Fatal: Error in configuration file /etc/dovecot/dovecot.conf line 68: Unknown setting: default_mail_env


This shows that due to the configuration issues in the file /etc/dovecot/dovecot.conf, the dovecot service failed to start. This clearly shows there’s an invalid parameter default_mail_env in this file.


How we fix?

Here, our Hosting Experts check and correct the configuration issues in the IMAP configuration file. Most importantly, we ensure there’s a valid backup of the configuration file before making any changes.

Similarly in courier-imap servers, we run the service with default configuration. For that, we backup the original configuration file and replace it with /etc/courier-imap/imapd.dist. If it works fine, we compare the original file and .dist file and fix the errors.

Further, we make sure that the dovecot service has been restarted successfully and running fine in the server. Moreover, we make sure that we can login to the email account via any webmail clients such as Roundcube, Horde, etc.


3) Server firewall restrictions

Another probable reason for this error is faulty firewall configuration in the server. We’ve seen instances where remote server blocks connection from particular IP address or IP address ranges. Remote server blocks connections from an IP address due to abnormal activities, too many connections, etc.

Similarly, the default IMAP port is 143 and Secure IMAP port(SSL/TLS port) is 993. And, if these ports are not opened in the server, customers will receive this error.


How we fix?

Firstly, our Support Engineers ensure that the IP address of the customer isn’t blocked in the server firewall. For example, on cPanel servers, we use the below command to check if the customer’s IP address xx.xx.xx.xx is blocked.

csf -g xx.xx.xx.xx


And if it’s blocked, we’ll immediately remove the block and restore the email service for the customer. Later, we find the reason for the block and update the customer about the preventive actions to be taken.

Moreover, we get the telnet results from customer’s end to check the IMAP port connectivity.

telnet xx.xx.xx.xx 143
telnet xx.xx.xx.xx 993


And, we’ll remove the offending rule from the server firewall. In addition to that, we modify the firewall settings to accept valid connections on IMAP ports 143 and 993.


4) Firewall restrictions at local end

Similarly, another possibility is that firewall on the customer’s network or ISP blocks the port for IMAP. We’ve seen cases where third party firewall or Antivirus program on the systems block IMAP port.


How we fix?

If there are no problems at the server side, we update customers to disable the security applications like Windows firewall, Antivirus programs, etc. one by one. This helps us to identify which program is creating problems and fix it’s settings.

Alternatively, if the issue is at the ISP level, we get the traceroute and tcptraceroute results from the customer. This helps us to identify if the problem lies at the intermediate level.



In short, imap connection refused error can occur due to server firewall restrictions, IMAP configuration issues, and more. Today, we’ve discussed the top 4 reasons for thus error and how our Dedicated Engineers fix them.

Leave a Comment

Your email address will not be published. Required fields are marked *

Social Share


Cheapest Web Hosting

Fasters Web Hosting Promo
Scroll to Top

Launch your Website at RS599

Create a professional website yourself with our domain hosting combo. Get Extra benefits at this Year end Sale with 10% OFF and Enjoy Amazing Deels on Shared Hosting!

Starting at Only RS599/Year

Year End Sale


Use Code STARTBIZ at Checkout.

Create an earning opportunity with A Web Hosting Business

Become reseller and start reselling domains, web hosting, ssl certificates and More.

45% OFF

Starting at RS399/Month


Use coupon: at the checkout.