postfix, cannot connect to mysql server localhost

When trying to run Postfix with virtual maps in MySQL, you can get the following error:

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

This error is because postfix is running in chroot /var/spool/postfix. So it cannot find the unix socket for MySQL.

If you have the option to run mysql on or on another IP, simply go to;



grep localhost *

and replace all localhost to or the IP in all files starting with mysql-virtual.

If you insist on running via unix sockets, you can simply fix it by running;

mkdir /var/spool/postfix/var
mount –bind /var /var/spool/postfix/var

Ater this, all will work fine.

Be the first to leave a comment. Don’t be shy.

Join the Discussion

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=""> <s> <strike> <strong>