I have two Raspbery PI 3 which I have installed (almost) identical. The configuration of /etc/mysql/mariadb.conf.d/50-server.cnf is identical for both Raspberrys.

Problem: I can only connect to the mysql database of one of these Raspberrys (using MySQL Workbench). So I looked for the problem and found a more "low level" problem: even telnet is not working on one of these Raspberrys.

telnet raspberry1 3306

works perfect, while

telnet raspberry2 3306

tells me that a connection cannot be established.

A ping works from my windows pc to both raspberrys.
A local connection to the MySQL server also works on both Raspberrys.

I even tried to disable any firewall on raspberry2 using sudo /sbin/iptables --flush

When using a port scanner like sudo nmap -sS -O raspberry1 raspberry2 I see that port 3306 is open on raspberry1 but not on raspberry2.

sudo netstat -ln gives me a slightly different output on both RPi's:

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0  *               LISTEN
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0*               LISTEN

As mentioned above the file 50-server.cnf is identical on both raspberries - especially the line bind-address = is set in both files.
(I also restarted raspberry2 using sudo /etc/init.d/mysql restart. I even restarted Raspbian.)
I still have no clue where the Local Address comes from.

Where could be differences in the configuration of the second Raspberry Pi?

  • how are you running the telnet commands?
    – jsotola
    Commented May 19, 2018 at 22:34
  • @jsotola: On a windows computer I entered the commandline (cmd) and sent the commands ("telnet raspberry2 3306") Commented May 20, 2018 at 10:58
  • @Fabian: I try to connect to the database using the program "MySQL Workbench". But this can't work as long as telnet isn't able to get a connection. With my question I ask for ideas, which differences between both Raspberrys could cause this problem. Commented May 20, 2018 at 11:25
  • Any firewalls in the mix, either on the network or on the server? Might they be doing an IP whitelist or similar?
    – Paul
    Commented May 20, 2018 at 13:51
  • 1
    please run on both RPis sudo netstat -ln | grep 3306 and post the result
    – Fabian
    Commented May 20, 2018 at 21:34

1 Answer 1


By default, the MariaDB server listens for TCP/IP connections on a network socket bound to a single address [...] In Debian [...] the default bind_address is, which binds the server to listen on localhost only.

source: Server System Variables - MariaDB Knowledge Base

sudo netstat -ln shows in the column "Local Address" for your raspberry1 "" (all IPv4s are allowed to access this device on port 3306) and for your raspberry2 "" (only localhost is allowed):

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0  *               LISTEN
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0*               LISTEN

This is the reason why you can connect to raspberry1 on port 3306, but not to raspberry2 on the same port. To make your raspberry2 accessible just set the correct bind_address in mycnf.

Security advice: If your RPis are not behind a well managed firewall, please read why it is a bad idea to allow direct connections to your databases and how you can configure MariaDB in a safe way for remote client access.

  • Both files 50-server.cfg already contain bind-address = and I restarted the mysql server (and even the whole operating system). I still get the Local Address Do you know if there is any way how the setting in the config file may be overwritten (e. g. by command line param)? My problem still exists :-( Commented May 21, 2018 at 20:32
  • @MichaelHutter for testing purposes set the bind_address at 50-server.cfg to a different IPv4 from you network, i.e. and restart. Then run again netstat and let me know the result (maybe you've edited the wrong config file).
    – Fabian
    Commented May 21, 2018 at 21:13
  • I found my mistake. I had a second (backup) file with extension .cnf in the folder /etc/mysql/mariadb.conf.d. This file was additionally executed after my real .cnf file. Now with your answer I am able to connect to the database. Thank you very much! Commented May 22, 2018 at 20:43
  • @MichaelHutter Glad to hear it's solved! Cheers!
    – Fabian
    Commented May 22, 2018 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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