Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm following the well-known tutorial, and I'm at this step

However I've got a problem when trying to run

postmap -q mysql:/etc/postfix/

I get:

postmap: warning: connect to mysql server Lost connection to MySQL server at 'reading initial communication packet', system error: 0

However I am able to connect to mysqld via mysql: mysql -u mailuser -p, with the password "foo". The .cf looks like this:

user = mailuser
password = foo
hosts =
dbname = mailserver
query = SELECT 1 FROM virtual_domains WHERE name='%s'

What could be the problem?


The relevant part from looks like this:

# The MySQL server
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 16K
myisam_sort_buffer_size = 8M

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
bind-address =
share|improve this question
up vote 1 down vote accepted

run postmap with more verbose output and post the output here. Hopefully you get some useful information out of it.

postmap -vvvq mysql:/etc/postfix/
share|improve this answer
Thank You, fixed it by setting hosts = localhost – Flavius A Feb 18 '10 at 18:49

mysqld can listen both to a local socket and a tcp/ip socket. By default it connects to the local socket (which is how you are connecting to it when running "mysql" on the command line). postgres is trying to connect via a tcp/ip socket on localhost and is not succeeding.

So, make mysqld listen on both interface types (or figure out why it's not if it's supposed to be), or make postgres use the local socket.

To simulate what postgres is doing from the command line BTW, you can run it like this:

mysql -u mailuser -h -p
share|improve this answer
Uhm, mysqld is configured to listen on which basically means all ifaces, right? Anyway I'll add to the question. Oh, and I see it listens on with nestat -tlnp – Flavius A Feb 18 '10 at 17:58
iptables? (......) – jj33 Feb 18 '10 at 18:07
no iptables, /etc/hosts.allow is: 3306 : ALL : allow – Flavius A Feb 18 '10 at 18:42

Your Answer


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

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