Report this

What is the reason for this report?

Why is postfix not connecting to mysql?

Posted on March 9, 2015

I upgraded some of my software and since then my postfix dovecot mysql setup that was working perfectly (following this tutorial) is broken…

I am currently running the following on my droplet:

  • Ubuntu 14.04.2 LTS Release: 14.04 Codename: trusty
  • Postfix 2.11.0
  • mysql 14.14 Distrib 5.6.23-72.1, for debian-linux-gnu (x86_64) using EditLine wrapper (Percona version)
  • dovecot 2.2.9

I can connect to mysql, and both postfix and dovecot are running. For some reason it appears that postfix cannot connect to the mysql server, even though the user and password work when I access the database directly. The error seems to be reflected by these repeating warnings in the postfix log file: (the hostname and username were changed for privacy)

<lots of stuff deleted>
Mar 8 18:25:58 hostname postfix/cleanup[31858]: warning: connect to mysql server 127.0.0.1: Lost connection to MySQL server at 'reading initial communication packet', system error: 0
Mar 8 18:25:58 hostname postfix/cleanup[31858]: warning: mysql:/etc/postfix/mysql-virtual-alias-maps.cf lookup error for "username@hostname"
Mar 8 18:25:58 hostname postfix/cleanup[31858]: warning: 149EB1845F3: virtual_alias_maps map lookup problem for username@hostname -- message not accepted, try again later
<lots of stuff deleted>

When I change the .cf files that define the mysql connections and use “localhost” instead of “127.0.0.1” the error message changes to:

<lots of stuff deleted>
Mar 8 18:30:52 hostname postfix/cleanup[32254]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Mar 8 18:30:52 hostname postfix/cleanup[32254]: warning: mysql:/etc/postfix/mysql-virtual-alias-maps.cf lookup error for "username@hostname"
Mar 8 18:30:52 hostname postfix/cleanup[32254]: warning: 0A28C1845F3: virtual_alias_maps map lookup problem for username@hostname -- message not accepted, try again later
<lots of stuff deleted>

Any thoughts how to troubleshoot this further? I have tried pretty much everything for the last six hours but don’t seem to have any success. I posted this to the entry that provides the tutorial, but thought this area might have a bit more traffic…

Thanks for your input!

Andreas

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.