3

hi i keep getting this error in maillog.any ideas

Jul 22 10:16:52 veepiz opendkim[5145]: OpenDKIM Filter: Unable to bind to port inet:20209@localhost: Address already in use
Jul 22 10:16:52 veepiz opendkim[5145]: OpenDKIM Filter: Unable to create listening socket on conn inet:20209@localhost
Jul 22 10:16:52 veepiz opendkim[5145]: smfi_opensocket() failed

#ps aux | grep opendkim
opendkim  1361  0.0  0.1  40424   780 ?        Ss   10:11   0:00 /usr/local/sbin/opendkim -x /etc/opendkim.conf
opendkim  1362  0.0  0.2  56948  1508 ?        Sl   10:11   0:00 /usr/local/sbin/opendkim -x /etc/opendkim.conf
opendkim  2256 19.6  0.1  40424   928 ?        Ss   10:16   1:18 /usr/local/sbin/opendkim -x /etc/opendkim.conf
root     20733  0.0  0.1  61224   740 pts/0    S+   10:23   0:00 grep opendkim


#netstat -nlp | grep 20209
tcp        0      0 127.0.0.1:20209             0.0.0.0:*                   LISTEN      1362/opendkim

4 Answers 4

4

The problem turned out to be a missing folder for the opendkim process that was specified in /etc/opendkim.conf:

PidFile /var/run/opendkim/opendkim.pid

I found this out by typing systemctl status opendkim.service after it failed to start.

Output:

● opendkim.service - LSB: Start and stop OpenDKIM
   Loaded: loaded (/etc/rc.d/init.d/opendkim)
   Active: failed (Result: timeout) since Sat 2016-05-28 20:16:56 CDT; 1min 40s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2640 ExecStart=/etc/rc.d/init.d/opendkim start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/opendkim.service
           ├─2643 /usr/local/sbin/opendkim -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid
           └─2645 /usr/local/sbin/opendkim -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid

May 28 20:11:56 alpha systemd[1]: Starting LSB: Start and stop OpenDKIM...
May 28 20:11:56 alpha opendkim[2640]: Starting OpenDKIM Milter: [  OK  ]
May 28 20:11:56 alpha systemd[1]: PID file /var/run/opendkim/opendkim.pid not readable (yet?) after start.
May 28 20:11:56 alpha opendkim[2643]: can't write pid to /var/run/opendkim/opendkim.pid: No such file or directory
May 28 20:11:56 alpha opendkim[2645]: OpenDKIM Filter v2.4.2 starting (args: -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid)
May 28 20:16:56 alpha systemd[1]: opendkim.service start operation timed out. Terminating.
May 28 20:16:56 alpha systemd[1]: Failed to start LSB: Start and stop OpenDKIM.
May 28 20:16:56 alpha systemd[1]: Unit opendkim.service entered failed state.
May 28 20:16:56 alpha systemd[1]: opendkim.service failed.

To fix this, I first stopped the opendkim process:

systemctl stop opendkim

Then I created a service that would make the dir at start:

vim /etc/systemd/system/georges.service

The contents of /etc/systemd/system/georges.service:

[Unit]
Description=George's Simple Service
After=network.target

[Service]
Type=simple
ExecStartPre=-/usr/bin/mkdir /var/run/opendkim
ExecStart=/usr/bin/chown opendkim:opendkim /var/run/opendkim
Restart=on-abort


[Install]
WantedBy=multi-user.target

Then I started this service:

systemctl start georges

systemctl status georges

Output:

[root@alpha etc]# systemctl status georges.service
● georges.service - George's Simple Service
   Loaded: loaded (/etc/systemd/system/georges.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

May 28 20:53:50 alpha systemd[1]: Starting George's Simple Service...
May 28 20:53:50 alpha systemd[1]: Started George's Simple Service.

Lastly I told the system to load it on startup:

systemctl enable georges

Not that I understand everything I did, but hey--it works for me! Feel free to let me know if I've wrecked anything by doing this...

UPDATE

I asked a question about this and they pointed out the correct way to have the system create a run directory:

Create this file:

/etc/tmpfiles.d/opendkim.conf

Drop in this one line (ok 2 if you count the comment):

#Type Path            Mode UID      GID    Age Argument
 d     /run/opendkim   0755 opendkim opendkim   -   -

Boom--it works just as well at reboot but doesn't require a new service to be configured.

3

Looks like you've already got at least one OpenDKIM process running, which is preventing it from starting a new one. Kill all the processes you found with ps aux | grep opendkim and then restart OpenDKIM.

2
  • If this fixed the problem, please mark your question as "answered."
    – SteveJ
    Aug 9, 2011 at 17:54
  • Perhaps it fixed my problem :) Jul 28, 2014 at 18:06
2

There is an "AutoRestart" option in dkim-filter.conf, which means that if the service is shutdown using "service dkim-milter stop", it will automatically restart itself. However, if you then try to start the service manually using "service dkim-milter start", it seems to create a second process and the server logs start filling up with the error message as the port is in use.

I have a script to manually check my mail server processes and restart them that was using the stop/start method, and experienced this problem.

Using "service dkim-milter restart" seems to work better, but occasionally I get the problem kicking in.

1

syntax, just rename Socket to SOCKET on DKIM-MILTER.CONF

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .