1

(Yes, this question seems very similar, but I understand why I get the message. What I don't get, and can't find any palpable information about on my own, is what to do about it. So here I am.)


I am trying to set up Postfix and Dovecot on my VPS, deciding to go the MySQL-route with MariaDB. Following this guide, which seems pretty okay.

Got as far as to test the DB config files with postmap, when the server simply refused connection. This is the error message I get;

postmap: warning: connect to mysql server 127.0.0.1: Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")
postmap: fatal: table mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf: query error: Transport endpoint is not connected

MariaDB's config file is set up to bind with 127.0.0.1, I opened 3306 for 127.0.0.1 and even tried disabling the firewall altogether without any change.

It seems that the IP and port can't be to blame then, and I assume this "Transport endpoint" must be the culprit - if that's not just another way of referring to the IP/port.

If anyone has suggestions as to what I can try to get around this, I would be incredibly grateful.

Edit: If it makes any difference, I'm using nginx as well.

Edit II: Results of 'service mysql status':

* /usr/bin/mysqladmin  Ver 9.1 Distrib 10.1.11-MariaDB, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Server version          10.1.11-MariaDB-1~trusty-log
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
Uptime:                 2 hours 37 min 16 sec
  • Output of systemctl mysqld status – Jacob Evans Jan 31 '16 at 17:46
  • @JacobEvans I added the output of service mysql status, which I assume does the same job. I see that it's connecting through the socket, but using localhost in the DB config for Postfix apparently is a no-go as far as all the information I've found on it is concerned. :') Maybe I should try using the UNIX socket path as host? – Aurora Vollvik Jan 31 '16 at 19:09
  • 2
    Possible duplicate of [What causes the 'Connection Refused' message?](http://serverfault.com/questions/725262/what-causes-the-connection-refused-message) – user9517 Jan 31 '16 at 19:10
  • 1
    In response to your edit and as Iain suggested: Is MariaDB actually listening for TCP connections on the default port? (That's port 3306) If it is, then be aware that GRANT-ing rights for TCP connections is different from allowing access from localhost.. – HBruijn Jan 31 '16 at 19:38
  • @HBruijn Using the command "netstat -tln" shows that nothing is indeed listening on 3306. Huh. Guess I have to find out what GRANT-ing is about then. :) – Aurora Vollvik Jan 31 '16 at 19:59
  • @HBruijn Oh, I see! Or I think I do. You mean adding a record in the user table of MariaDB to let the user connect through TCP? But it's still not listening for connections though. Gotta figure it out! :) – Aurora Vollvik Jan 31 '16 at 20:04
  • Can you log in with mysql -h127.0.0 1 – Jacob Evans Jan 31 '16 at 20:19
  • Okay, thank you for pointing me in the right direction @HBruijn! I disabled the 'skip-networking' directive in my.cnf and restarted MariaDB, and now it listens to 127.0.0.1! I was actually looking at it before too, but I thought it was only for _remote_ access, so I didn't think that's what I needed! – Aurora Vollvik Jan 31 '16 at 20:21
  • Looks like a config issue, or you never restarted the service. Post your configuration and what system you're using. – Jacob Evans Jan 31 '16 at 20:21
  • You're right, it was a config issue. The skip-networking directive was shutting off TCP completely, but I thought I'd open for remote access if I disabled it. Took a second look at this page, and voila! https://mariadb.com/kb/en/mariadb/configuring-mariadb-for-remote-client-access/ – Aurora Vollvik Jan 31 '16 at 20:24

1 Answers1

1

I found the answer here, after HBruijn set me on the right path: https://mariadb.com/kb/en/mariadb/configuring-mariadb-for-remote-client-access/

MariaDB has the skip-networking directive active as default, which stops all TCP/IP connections. After commenting it out, but leaving bind-address as is I let MariaDB listen to TCP on the default port (3306) only for local connections.

Change this in my.cnf:

#skip-networking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1

Restarted the mysql service and tested to see what ports were listened on;

# netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
..some records..
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN

Also successfully logged into MariaDB through 127.0.0.1, and everything works! Yay!

# mysql -u mailuser -h 127.0.0.1 -D mailserver -p
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 49
Server version: 10.1.11-MariaDB-1~trusty-log mariadb.org binary distribution

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mailserver]>It finally works!