Search code examples
mysqldebianpostfix-mtawebmail

Postfix MySQL Error 111


Ok so im setting up a postfix sql connection and for some weird reason, the same account that is accessing the previous two maps is now refusing the connection to 127.0.0.1. Two Connections are already working with the same credentials.

The first file the one with the issue (111)

user = exampleadmin

password = bgfoenawox

hosts = 127.0.0.1

dbname = exampleserver

query = SELECT destination FROM virtual_aliases WHERE source='%s'

This gives me the following error in putty,

postmap: warning: connect to mysql server 127.0.0.1:Can't connect to MySQL server on '127.0.0.1' (111)

postmap: fatal: table mysql:/etc/postfix/mysql-virtual-alias-maps.cf: query error: Connection refused

Working virtual email maps.

user = exampleadmin

password = bgfoenawox

hosts = 127.0.0.1

dbname = exampleserver

query = SELECT 1 FROM virtual_users WHERE email='%s'

This gives me the following result in putty,

 1

Working virtual domain maps

user = exampleadmin

password = bgfoenawox

hosts = 127.0.0.1

dbname = exampleserver

query = SELECT 1 FROM virtual_domains WHERE name='%s'

This gives me the following result in putty,

 1

I am following this guide here. Postfix Guide


Solution

  • Answer!

    Finally, that didnt take long.

    If anyone is having this issue, please try this.

    nano /etc/postfix/mysql-virtual-alias-maps.cf

    Change the hosts to

    From : 127.0.0.1 > HOSTNAME e.g. server54

    This will enable the connection to the localhost. And show the correct postmap.

    postmap -q [email protected] mysql:/etc/postfix/mysql-virtual-alias-maps.cf

    Result?

    Your email address ([email protected])