Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 127.0.0.1: Can't connect to MySQL server on '127.0.0.1' (110)

In mysql-domains.cf I'm using:

Hosts    127.0.0.1

I can connect to MySQL with this:

mysql -u postfixuser -p

But I can't connect this way:

mysql -u postfixuser -h 127.0.0.1 -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            = 127.0.0.1

Any idea what could be wrong?

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

2 Answers 2

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

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

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

grant all on postfix.* to postfix@127.0.0.1 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.

share|improve this answer
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 127.0.0.1 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 127.0.0.1 on port 3306.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.