How to change the default Dovecot’s ports

Dovecot is a very used open-source IMAP and POP3 server. By default, the email ports are:

Mail ProtocolPort
POP3 (Post Office Protocol)110
IMAP (Internet Message Access Protocol)143
POP3S (POP3 over SSL/TLS)995
IMAPS (IMAP over SSL/TLS)993
Email protocols/ports

There can be cases where you might want to change a default port. For example, if on your local network the port 110 is blocked. We will show here how to change the ports.

Open Dovecot’s configuration file – /etc/dovecot/dovecot.conf – and locate these lines:

service imap-login {
   process_min_avail = 16
   user = dovecot
}
service pop3-login {
   process_min_avail = 16
   user = dovecot
}

Update them as needed with:

service imap-login {
   process_min_avail = 16
   user = dovecot

   inet_listener imap {
      port = 143
   }
   inet_listener imaps {
      port = 993
      ssl = yes
   }
}
service pop3-login {
   process_min_avail = 16
   user = dovecot

   inet_listener pop3 {
      port = 110
   }
   inet_listener pop3s {
      port = 995
      ssl = yes
   }
}

When done restart the Dovecot server with:

service dovecot restart

To verify the port(s) change, you can use the netstat command:

netstat -tlp | grep -i dovecot

netstat -tlpn | grep -i dovecot
[root@web ~]# netstat -tlp | grep -i dovecot
tcp        0      0 0.0.0.0:pop3            0.0.0.0:*               LISTEN      500/dovecot
tcp        0      0 0.0.0.0:imap            0.0.0.0:*               LISTEN      500/dovecot
tcp        0      0 0.0.0.0:imaps           0.0.0.0:*               LISTEN      500/dovecot
tcp        0      0 0.0.0.0:pop3s           0.0.0.0:*               LISTEN      500/dovecot

[root@web1 ~]# netstat -tlpn | grep -i dovecot
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      500/dovecot
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      500/dovecot
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      500/dovecot
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      500/dovecot

Notice that DirectAdmin will not overwrite the Dovecot‘s configuration file on updates.

Leave a Reply