5

I'm currently trying to use some "me@mydomain.com" adresses on my dedicated server (Centos5).

To do so, I'm tring to launch dovecot with /etc/init.d/dovecot start, but I get the following error message :

Starting Dovecot Imap: Error: service(pop3-login): listen(*, 110) failed:
Address already in use
Error: service(pop3-login): listen(*, 995) failed: Address already in use
Error: service(imap-login): listen(*, 143) failed: Address already in use
Error: service(imap-login): listen(*, 993) failed: Address already in use
Fatal: Failed to start listeners
                                                           [FAILED]

Something is already listening on these ports, but I don't know what. Qmail was previously installed on my server, so I removed it, but it didn't solve the problem.

Do you know how to fix this ?

Nicolas Reynolds
  • 177
  • 1
  • 1
  • 8

6 Answers6

9

Just did an upgrade on an AWS Linux instance and dovecot wouldn't start with Address already in use errors (same as original poster).

netstat and lsof didn't show any process attached to those TCP ports.

Eventually I discovered that as part of the upgrade the portreserve package was installed. It had a config file /etc/portreserve/dovecot which had listed the problematic ports. I renamed the file to /etc/portreserve/dovecot~ and now everything works fine.

According to https://bugzilla.redhat.com/show_bug.cgi?id=1570282 because portreserve only does a bind() to the port, and doesn't do a listen() it won't show up in lsof or netstat. That makes it really tricky to troubleshoot.

rsfault
  • 91
  • 1
  • 2
  • Same problem here. Dovecot was the only thing registered, so removing /etc/portreserve/dovecot prevents portreserve from starting at all. i.e., 'service portreserve start' produces "Starting portreserve: (not starting, no services registered)" – Jef Jul 01 '20 at 15:49
  • 1
    Apparently the missing /etc/portreserve/dovecot file can be replaced by the amazon "yum update" process, so it may be better to leave it in-place, and simply edit it. – greeble31 Oct 30 '20 at 15:18
  • @greeble31 you are correct - much better to edit rather than delete. Since I'd removed the file, I just did an update and it put the (bad) file back. – rsfault Nov 12 '20 at 01:43
  • Same here, but I also had to restart portreserve to get it to release the ports used by the file: service portreserve restart (or you could probably just stop the service and disable it). – Russell G Nov 26 '20 at 14:40
4

This command will show you what's listening:

$ sudo netstat -lnp | grep 993
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      4470/imap-login

The last column gives you the PID and name of the process bound to that particular port.

Flup
  • 7,978
  • 2
  • 32
  • 43
1

Edit dovecot conf and replace :

protocols = imap pop3 imaps pop3s

with

protocols = imap pop3

You might be missing the certificate for SSL ports.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
Razvan
  • 11
  • 1
0

Nothing worked for me - the issue was I had portreserve service running via init.d. Had to disable the service before starting dovecot services:

portreserve stop

Stopping portreserve: [ OK ]

./dovecot start

Starting Dovecot Imap: [ OK ]

0

I found it was dovecot only on that PID

I ran kill dovecot followed by dovecot it worked fine!

KawaiKx
  • 101
  • 1
0

This happened to me just now. Disabling the imaps protocol, did not work for some reason, dovecot still tried to open port 993, possibly something to do with startTLS. Anyway netstat did not show any active listening ports:

samuel@extern:/etc/dovecot$ sudo netstat -tulpn | grep 993
samuel@extern:/etc/dovecot$

I did have one ESTABLISHED port tho:

samuel@extern:/etc/dovecot$ sudo netstat -tulpan | grep 993
tcp        0      0 192.168.1.132:993       192.168.1.129:2049      ESTABLISHED -               
samuel@extern:/etc/dovecot$

When I rebooted the virtual machine Dovecot started working again. Further research showed that NFS was interfering. The problem started right after a reboot with:

dovecot: master: Error: service(imap-login): listen(*, 993) failed: Address already in use

NFS uses privileged ports to mount the remote filesystem for some reason. See: https://unix.stackexchange.com/questions/398152/why-is-nfs-client-using-low-numbered-ports

Samuel Åslund
  • 221
  • 2
  • 3