Connection Refuesed while connectiong IMAP and POP3 Servers

I have set up some domains on my server and I have enabled Mail for domain for all domains.

But when I try to connect to IMAP and POP3 server I’m getting this error : ConnectException: Connection refused

I can’t find any error report in log files, also I’m not sure about whicg log file to check.

What must be the next step for me? Can you please help me on fixing this error.


Operating system Ubuntu Linux 12.04.1
Webmin version 1.610
Virtualmin version 3.97.gpl GPL
Theme version 8.5
Kernel and CPU Linux 3.2.0-34-generic on x86_64


You’d want to check /var/log/mail.log for errors regarding email.

Also, you may want to verify that Dovecot is running – you can do that with this command:

/etc/init.d/dovecot restart

Andrey Thanks for help,

After getting your response, I have restarted dovecot and tried to connect again.
Result was the same, connection refused.

Also, There is no new record populated in to /var/log/mail.log the lastest record belongs to 1 hour ago.

Here is log file dump :

This can have any number of reasons.

From where exactly are you trying to connect to where? Regular or SSL port? Any routers or firewalls involved? Can you ping the server? Are you using IPs or hostnames? Does the hostname resolve?

You might want to check if Dovecot running on your server and listening on all IPs: netstat -tpln | grep 143 should turn up results for Dovecot.

Check if a local firewall is blocking ports: iptables -L -n

Otherwise check with your hoster if ports need to be opened.

Hello Locutus,

No routers involved, and firewall doesn’t block any connection. I’m trying to connect from my local computer to

Dovecot serves mail protocols Pop3 and Imap, as SSL Enabled. I can ping the server. Ip resolves correct host name.

Here is output of netstat and iptables output.

root@mydomain ~ # netstat -tlpn | grep 143 tcp 0 0* LISTEN 7954/dovecot tcp6 0 0 :::143 :::* LISTEN 7954/dovecot root@mydomain ~ # iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT udp -- udp dpt:53 ACCEPT tcp -- tcp dpt:20000 ACCEPT tcp -- tcp dpt:10000 ACCEPT tcp -- tcp dpt:443 ACCEPT tcp -- tcp dpt:80 ACCEPT tcp -- tcp dpt:993 ACCEPT tcp -- tcp dpt:143 ACCEPT tcp -- tcp dpt:995 ACCEPT tcp -- tcp dpt:110 ACCEPT tcp -- tcp dpt:20 ACCEPT tcp -- tcp dpt:21 ACCEPT tcp -- tcp dpt:53 ACCEPT tcp -- tcp dpt:587 ACCEPT tcp -- tcp dpt:25 ACCEPT tcp -- tcp dpt:22

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Now, I have realized that I can connect to server on localhot, but It terminates remote connections.
Here is

It terminates connection after 8-10 secounds.

Is this server on an internal LAN, with an internal IP address?

If so, can you try connecting using that internal IP address, rather than the domain name, and see if that makes a difference?


Uuhm, according to your pastebin, when connecting from the remote site, you connected to port 443? That’s HTTPS, why do you connect to that when you want to test IMAP?

I guess it’s expected behavior that the HTTPS daemon waits for a few seconds for the client to initiate the SSL setup, and closes the connection when nothing happens. :slight_smile: HTTPS does not have any “greeting line” from the server.