I just installed Postfix and configured it to use MySQL. It wasn't sending any emails out after I did that so I checked /var/log/mail.log and it came back with this:

postfix/trivial-rewrite[5283]: fatal: proxy:mysql:/etc/postfix/mysql-domains.cf(0,lock|fold_fix): table lookup problem
postfix/cleanup[5258]: warning: AFCDC30437: virtual_alias_maps map lookup problem for email@email.com
postfix/master[4761]: warning: process /usr/lib/postfix/trivial-rewrite pid 5282 exit status 1
postfix/proxymap[4126]: warning: connect to mysql server Can't connect to MySQL server on '' (110)

In mysql-domains.cf I'm using:


I can connect to MySQL with this:

mysql -u postfixuser -p

But I can't connect this way:

mysql -u postfixuser -h -p maildbname

Also when I run netstat -l it comes back with:

tcp        0      0 localhost:mysql         *:*                     LISTEN

I've tried changing my hosts to:

Hosts    localhost

But then I just get a socket error:

postfix/cleanup[4870]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

I also have this set up in the MySQL config file:

bind-address            =

Any idea what could be wrong?

  • Be aware that localhost != in mysql. When you use "localhost" in mysql it attempts to use the socket instead of a tcp connection to – Craig Nov 11 '11 at 4:20

In your postfix mysql connection section, I think you want:

hosts = unix:/var/run/mysqld/mysqld.sock

rather than for postfix. Alternatively, add a grant to allow postfix to connect via rather than localhost.

grant all on postfix.* to postfix@ identified by 'asdf';

Postfix is connecting via TCP, you probably have the grant defined for the socket connection. Fixing one or the other should fix it.

  • 1
    Ok....neither one of those worked either, but I think I found out what my problem was. I apparently botched something up in the reverse DNS. So I fixed that and now it seems to work. – Andrew Dakin Apr 7 '10 at 19:40

I suspect a firewall might be messing things up. Try telnetting to localhost on port 3306: telnet localhost 3306 or telnet 3306 and see if that connects.

If it does not, try disabling your firewall: sudo ufw disable, then try telnetting again. If it does connect, we've identified your firewall settings as being the culprit, you will need to allow TCP access on your lo interface to/from on port 3306.

Your Answer

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