HowTo: Fix Postgrey not working after upgrading from an older version of Ubuntu to a newer version.

Scenario: You’ve got some Postfix mail servers running with Postgrey for anti-spam greylisting. They’re all using older versions of Ubuntu such as 10.04 LTS. You’ve decided that it’s time to upgrade them to the next LTS, Ubuntu 12.04.

You do the upgrade and it goes without a hitch. You restart the server, everything looks good, until you start seeing this message in your server’s mail log:

 

Jan 23 21:17:58 mymailserver postfix/smtpd[7976]: connect from somecompany.com[100.200.300.400]
Jan 23 21:17:59 mymailserver postfix/smtpd[7976]: warning: connect to 127.0.0.1:10023: Connection refused
Jan 23 21:17:59 mymailserver postfix/smtpd[7976]: warning: problem talking to server 127.0.0.1:10023: Connection refused
Jan 23 21:18:00 mymailserver postfix/smtpd[7976]: warning: connect to 127.0.0.1:10023: Connection refused
Jan 23 21:18:00 mymailserver postfix/smtpd[7976]: warning: problem talking to server 127.0.0.1:10023: Connection refused
Jan 23 21:18:00 mymailserver postfix/smtpd[7976]: NOQUEUE: reject: RCPT from somecompany.com[100.200.300.400]: 451 4.3.5 Server configuration problem; from=<m-1wu7GywwdBK9XOl40cdonjrOvQVbXrSQjrNIttfwaHqBuxTEiR4njb_
n@bounce.somecompany.com> to=<myrecipient@mycompany.com> proto=ESMTP helo=<mail.somecompany.com>
Jan 23 21:18:05 mymailserver postfix/smtpd[7976]: disconnect from somecompany.com[100.200.300.400]
Jan 23 21:18:10 mymailserver postfix/smtpd[7955]: connect from unknown[200.300.400.500]
Jan 23 21:18:11 mymailserver postfix/smtpd[7955]: warning: connect to 127.0.0.1:10023: Connection refused
Jan 23 21:18:11 mymailserver postfix/smtpd[7955]: warning: problem talking to server 127.0.0.1:10023: Connection refused
Jan 23 21:18:12 mymailserver postfix/smtpd[7955]: warning: connect to 127.0.0.1:10023: Connection refused
Jan 23 21:18:12 mymailserver postfix/smtpd[7955]: warning: problem talking to server 127.0.0.1:10023: Connection refused
Jan 23 21:18:12 mymailserver postfix/smtpd[7955]: NOQUEUE: reject: RCPT from unknown[200.300.400.500]: 451 4.3.5 Server configuration problem; from=<someone@anothercompany.com> to=<myrecipient@mycompany.com> proto=ESMTP helo=<m
ail.anothercompany.com>
Jan 23 21:18:12 mymailserver postfix/smtpd[7955]: disconnect from unknown[200.300.400.500]
Jan 23 21:18:17 mymailserver postfix/smtpd[7976]: connect from mta.ilikecheese.com[300.400.500.600]
Jan 23 21:18:18 mymailserver postfix/smtpd[7976]: warning: connect to 127.0.0.1:10023: Connection refused
Jan 23 21:18:18 mymailserver postfix/smtpd[7976]: warning: problem talking to server 127.0.0.1:10023: Connection refused
Jan 23 21:18:19 mymailserver postfix/smtpd[7976]: warning: connect to 127.0.0.1:10023: Connection refused
Jan 23 21:18:19 mymailserver postfix/smtpd[7976]: warning: problem talking to server 127.0.0.1:10023: Connection refused
Jan 23 21:18:19 mymailserver postfix/smtpd[7976]: NOQUEUE: reject: RCPT from mta.ilikecheese.com[300.400.500.600]: 451 4.3.5 Server configuration problem; from=<someone@thatcompany.com> to=<myrecipient@mycompany.com> pro
to=ESMTP helo=<MTA.thatcompany.com>
Jan 23 21:18:20 mymailserver postfix/smtpd[7976]: disconnect from mta.thatcompany.com[300.400.500.600]

You almost have a heart attack – every single email is bouncing back and it’s clear that it’s something to do with your upgrade. What went wrong? The errors refer to a configuration issue, but you didn’t change any of the configuration in your upgrade!

Closer inspection reveals that for some reason, Postfix is unable pass messages onto Postgrey which is a local service running on port 10023 by default on Ubuntu systems. If you try telnetting to port 10023 on 127.0.0.1 , you also get a “connection refused” error. So what’s happened?

The answer is that somewhere between Ubuntu 10.04 and Ubuntu 12.04, Postgrey changed the protocol it binds on. It now binds to IPv6 instead of IPv4 so we need to make some minor changes to Postfix’s configuration to get Postgrey working again.

  1. First up, we need to stop mail being bounced. It’s better to have sending servers pool up mail a little and then send it all through at once later, so at a Terminal prompt on your server, type in:
    $ sudo service postfix stop
  2. Now we need to edit Postfix’s configuration file:
    $ sudo nano /etc/postfix/main.cf
  3. Scroll down until you can see the line inside the “smtp_recipient_restrictions” section that directs Postfix to send mail to Postgrey for checking (or use CTRL+W to search for it), which looks like this:
    check_policy_service inet:127.0.0.1:10023,
  4. And now modify that line to look like the following. This will make Postfix pass on the mail to Postgrey using IPv6 instead of IPv4:
    check_policy_service inet:::1:10023,
  5. Now on a new line outside of the “smtp_recipient_restrictions” section, add the following line:
    inet_protocols=all
  6. Save your changes by pressing CTRL+X, then “Y” and then Enter.
    .
  7. Now we can restart Postfix with:
    $ sudo service postfix restart
  8. Now start tailing your log with the “follow” parameter using the following command:
    $ tail -f /var/log/mail.log
  9. Now send a test email and watch what new information appears in the terminal log. This time the mail should be successfully received and processed as normal.
    .
  10. Pat yourself on the back and breath a sigh of relief.

  (2212)

Category(s): Tutorials
Tags: , , , , , , , , , ,

Leave your comments below!

Loading Facebook Comments ...

7 Responses to HowTo: Fix Postgrey not working after upgrading from an older version of Ubuntu to a newer version.

  1. Problem exists in my case still again. What could be wrong?

  2. Try restarting Postgrey first and then restart Postfix.

    Also, just confirm that your loopback interface has an IPv6 address. It should, but just check anyway.

  3. Hello

    This is exactly the behaviour of Postgrey I found on my system. Thanks a lot for this solution, it works perfectly on my system, so I finally can say my system has been migrated to 12.04 in the end.

    Best Regards,
    Martin

  4. Hi there.

    Thank you very much for pointing exactly to the problem that I had on my system.
    Upgrading from Ubuntu 10.4 LTS to 12.04 LTS caused this effect.
    My email server is working flawlessly again after this fix.

    Regards
    Stian

  5. Thank you!
    Saved my day, great job!

    Regards
    Piotr

  6. It’s not working for me. Postgrey itself is not starting. If I call “service postgrey start” it says [OK] but there is not postgrey process if I call “ps aux”. Smilie: :(

  7. Try and run postgrey directly instead of via the init script and see if it gives you any indication as to why it’s aborting itself.

One Response in another blog/article

  1. […] Nach einem Update des Mailserver ist mir aufgefallen, dass Postgrey verbindungen über IPV6 anbietet. Dazu gibt es hier eine kurze Anleitung […]

Add Comment Register



Leave a Reply

Your email address will not be published. Required fields are marked *

 

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree

  1. […] Nach einem Update des Mailserver ist mir aufgefallen, dass Postgrey verbindungen über IPV6 anbietet. Dazu gibt es hier eine kurze Anleitung […]