newspaint

Documenting Problems That Were Difficult To Find The Answer To

Systemd Listening on Port

You perform a netstat and discover that systemd is listening on a port that it shouldn’t be occupying:

me@server:~$ sudo netstat -apn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address  Foreign Address  State   PID/Program name
tcp        0      0 0.0.0.0:993    0.0.0.0:*        LISTEN  1/systemd
tcp        0      0 0.0.0.0:143    0.0.0.0:*        LISTEN  1/systemd

What can be done about this? You can discover which sockets have been configured by running:

me@server:~$ sudo systemctl list-sockets
LISTEN       UNIT            ACTIVATES
...
0.0.0.0:143  dovecot.socket  dovecot.service
0.0.0.0:993  dovecot.socket  dovecot.service
[::]:143     dovecot.socket  dovecot.service
[::]:993     dovecot.socket  dovecot.service
...

In this case we see that “dovecot.socket” is the unit responsible for the binding of these ports.

In the short term you may want to kill the socket to release the port:

me@server:~$ sudo systemctl kill dovecot.socket

… but long term you may want to delete the unit and prevent the ports from being bound in the first place:

me@server:~$ sudo mv /lib/systemd/system/dovecot.socket

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: