I have the problem with configuration of Postfix on my server. I have been used this link like tutorial for creating and configuration Postfix.


But, when I tried to test Postfix with command: postmap -q example.com mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf

I got the error: postmap: warning: connect to mysql server Can't connect to MySQL server on '' (111) postmap: fatal: table mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf: query error: Connection refused

When I tried to test it with command: telnet 3306 or telnet localhost 3306

I got the error: Trying telnet: Unable to connect to remote host: Connection refused

MySQL server worked and I couldn't find a way to fix this error.

Does somebody know what is the problem?


This error is telling you that MySQL isn't listening on the port specified.

Can you connect to MySQL using the command line client (e.g. mysql -H127.0.0.1 -P3306?)

I doubt you can if both postmap and telnet are telling you they can't connect. Check the port that you're using - has this been changed from the default? Look in /etc/my.cnf as a first port of call for the current MySQL server config.

Check MySQL is running. Depending on your distribution and how you installed MySQL there are various ways to do this, but check the output of:

ps -ef | grep mysql

You should find at least one mysqld process running.

If it's not running, start the server. If you've got a relatively "normal" install, this can be done using init.d scripts as root (normally something like /etc/init.d/mysql start).


I had the same error. Was able to solve it using localhost instead of both in the GRANT SELECT and in mysql-virtual-mailbox-domains.cf

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.