20

I'm attempting to get postfix running on my server but keep getting the following error in my /var/log/mail.log:

postfix/master[5041]: fatal: bind 0.0.0.0 port 25: Address already in use

I did some searching and found this excellent answer by Oli (regarding this very question) in which it's recommended that I basically rid my server of sendmail packages to avoid conflicts, then reinstall postfix, which will in turn install its own brand of sendmail. Unfortuantely it didn't quite solve the problem (see below for how).

I followed the instructions and ran the following check, to which I received an encouraging response:

$ dpkg -S `which sendmail`
postfix: /usr/sbin/sendmail

However when I started postfix again, I got the same error.

As per Oli's contingency, I looked for the process that was hogging port 25 with the following:

$ sudo netstat -pel | grep smtp
tcp        0      0 localhost.localdom:smtp *:*                     LISTEN      root       
35704126    27626/sendmail: MTA

But here's where it got confusing: I then looked for the process 27626 but was then told:

dpkg-query: no path found matching pattern 27626
connections
.

I pulled up htop and was able to find the above PID associated with the following command:

sendmail:MTA: accepting connections

I then tried to kill the process with both killall sendmail and killall 27626 and kept getting no process found.

The problem is (besides the obvious) I don't know how to interpret these findings. I scrubbed the server of sendmail, so I can only assume that postfix's own version of sendmail is hijacking the port? I don't even know if that makes sense.

Anyway, if anyone could set me straight on this or at least give some interesting diagnostics questions, I'd appreciate it.

In case it's useful, I'm using virtualmin on the server to manage a few different domains and am also running wordpress.

Many thanks in advance!

In response to a request I've posted a ps -ef below

root@upsmart:~# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Jan12 ?        00:00:00 init
root         2     1  0 Jan12 ?        00:00:00 [kthreadd/20017]
root         3     2  0 Jan12 ?        00:00:00 [khelper/20017]
root        68     1  0 Jan12 ?        00:00:00 upstart-udev-bridge --daemon
root        75     1  0 Jan12 ?        00:00:00 /sbin/udevd --daemon
root       110     1  0 Jan12 ?        00:00:00 /usr/sbin/sshd -D
root       130    75  0 Jan12 ?        00:00:00 /sbin/udevd --daemon
root       131    75  0 Jan12 ?        00:00:00 /sbin/udevd --daemon
root       175     1  0 Jan12 ?        00:00:00 upstart-socket-bridge --daemon
116        205     1  0 Jan12 ?        00:00:03 dbus-daemon --system --fork --activation=upstart
root       385     1  0 Jan12 ?        00:00:00 /usr/sbin/dovecot -F -c /etc/dovecot/dovecot.conf
root       386     1  0 Jan12 ?        00:00:04 cron
mysql      410     1  0 Jan12 ?        00:08:06 /usr/sbin/mysqld
dovecot    441   385  0 Jan12 ?        00:00:00 dovecot/anvil
root       442   385  0 Jan12 ?        00:00:00 dovecot/log
root       444   385  0 Jan12 ?        00:00:00 dovecot/config
syslog     445     1  0 Jan12 ?        00:00:08 /sbin/syslogd -u syslog
bind       474     1  0 Jan12 ?        00:00:12 /usr/sbin/named -u bind
clamav     844     1  0 Jan12 ?        00:01:34 /usr/sbin/clamd
clamav     951     1  0 Jan12 ?        00:03:27 /usr/bin/freshclam -d --quiet
list       969     1  0 Jan12 ?        00:00:00 /usr/bin/python /usr/lib/mailman/bin/mailmanctl -s -q start
list       970   969  0 Jan12 ?        00:01:03 /usr/bin/python /var/lib/mailman/bin/qrunner --runner=ArchRunner:0:1 -
list       971   969  0 Jan12 ?        00:01:10 /usr/bin/python /var/lib/mailman/bin/qrunner --runner=BounceRunner:0:1
list       972   969  0 Jan12 ?        00:01:03 /usr/bin/python /var/lib/mailman/bin/qrunner --runner=CommandRunner:0:
list       973   969  0 Jan12 ?        00:01:07 /usr/bin/python /var/lib/mailman/bin/qrunner --runner=IncomingRunner:0
list       974   969  0 Jan12 ?        00:01:01 /usr/bin/python /var/lib/mailman/bin/qrunner --runner=NewsRunner:0:1 -
list       976   969  0 Jan12 ?        00:01:05 /usr/bin/python /var/lib/mailman/bin/qrunner --runner=OutgoingRunner:0
list       978   969  0 Jan12 ?        00:01:06 /usr/bin/python /var/lib/mailman/bin/qrunner --runner=VirginRunner:0:1
list       980   969  0 Jan12 ?        00:00:00 /usr/bin/python /var/lib/mailman/bin/qrunner --runner=RetryRunner:0:1
root      1410     1  0 Jan12 ?        00:00:00 /usr/sbin/saslauthd -a pam -m /var/spool/postfix/var/run/saslauthd -r
root      1413  1410  0 Jan12 ?        00:00:00 /usr/sbin/saslauthd -a pam -m /var/spool/postfix/var/run/saslauthd -r
root      2034     1  0 Jan12 ?        00:00:09 /usr/bin/perl /usr/share/usermin/miniserv.pl /etc/usermin/miniserv.con
proftpd   2054     1  0 Jan12 ?        00:00:07 proftpd: (accepting connections)              
root      2096     1  0 Jan12 ?        00:00:13 /usr/bin/perl /usr/share/webmin/miniserv.pl /etc/webmin/miniserv.conf
root      2173     1  0 Jan12 ?        00:00:15 /usr/sbin/console-kit-daemon --no-daemon
root      2241     1  0 Jan12 ?        00:00:07 /usr/lib/policykit-1/polkitd --no-debug
root      4895     1  0 03:15 ?        00:00:00 /usr/sbin/xinetd -dontfork -pidfile /var/run/xinetd.pid -stayalive -in
www-data  6494 30181  0 03:41 ?        00:00:06 /usr/sbin/apache2 -k start
www-data  6497 30181  0 03:42 ?        00:00:06 /usr/sbin/apache2 -k start
www-data  6499 30181  0 03:42 ?        00:00:06 /usr/sbin/apache2 -k start
www-data  6500 30181  0 03:42 ?        00:00:07 /usr/sbin/apache2 -k start
root      9477 30027  0 05:09 pts/5    00:00:00 sudo ps -ef
root      9478  9477  0 05:09 pts/5    00:00:00 ps -ef
root     27626     1  0 02:44 ?        00:00:00 sendmail: MTA: accepting connections          
root     27902   110  0 02:51 ?        00:00:01 sshd: root@pts/4    
root     27998 27902  0 02:51 pts/4    00:00:01 -bash
root     29931   110  0 02:59 ?        00:00:03 sshd: root@pts/5    
root     30027 29931  0 02:59 pts/5    00:00:00 -bash
root     30181     1  0 03:00 ?        00:00:02 /usr/sbin/apache2 -k start
www-data 30183 30181  0 03:00 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 30636 30181  0 03:06 ?        00:00:13 /usr/sbin/apache2 -k start
  • 2
    Have you rebooted the server? Looking at the comments from Oli's answer, the problem went away after a reboot. – douggro Jan 14 '14 at 15:50
19

I experienced the same issue on Ubuntu 16.04.01 LTS. The following log message occurred in /var/log/mail.log and outbound mail was failing to be sent out:

postfix/master[5072]: fatal: bind 127.0.0.1 port 25: Address already in use

I received the following output when trying to kill sendmail:

$ sudo killall sendmail
sendmail: no process found

The following commands worked for me (no need to reboot the server):

sudo killall sendmail-mta
sudo service postfix restart
|improve this answer|||||
  • 2
    That worked for me! Kudos! – Thelambofgoat Mar 21 '18 at 9:16
10

I had the same issue and what I did is only stop send mail, restart postfix and start again sendmail with the following commands:

service sendmail stop
service postfix restart
service sendmail start

Everything came back just fine.

|improve this answer|||||
9

Well the answer is profoundly unsatisfying but after burning some hours working on this today, I restarted the server and postfix is now running. Thanks all who lent some insight.

|improve this answer|||||
5

Just kill the sendmail process and try again:

sudo kill 27626

or

sudo killall sendmail
|improve this answer|||||
  • Thanks for the response Braiam. Should have specified in the question, I actually gave both of those a shot and it gives me a no process found. I'll update the question with that bit of info. – neanderslob Jan 14 '14 at 6:31
  • killall sendmail did not find any processes for me, yet ps aux | grep sendmail showed one running, and killing by its PID solved the issue. It was listed as sendmail: MTA:[...] so I'm guessing the actual daemon process was relabeled but goes by a different name. Unfortunately unable to investigate any further myself at this time, though. – Synexis Jan 23 '17 at 5:50
4

For me the solution was sudo killall sendmail-mta

|improve this answer|||||
1

You may use fuser command (as root) to get list of all processes listening on port 25 and kill them.

fuser -uv  25/tcp
fuser -kuv 25/tcp
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.