I am trying to connect to a MariaDB database on a Raspberry Pi 5 running Raspbian using DBeaver CE running on a Windows 11 PC on the same local area network.
I am getting the following error message in DBeaver CE:
Socket fail to connect to host address=(host=tachnitpi)(port=3306)(type=primary). Connection timed out: getsockopt
What is very frustrating is that I had this working at one time but after applying several updates in both Windows and on the RPi, the connection stopped working.
The Pi and the PC are both connected to the same switch on the same LAN. There's nothing going on with the router that would segregate these machines (and, as I mentioned, I was able to connect before several updates and reboots).
These are my DBeaver CE connection settings:
- Connect by: Host
- URL: jdbc:mariadb://tachnitpi:3306/tachnitdb (auto-populated)
- Server Host: tachnitpi
- Database: tachnitdb
- Username: moosewaredbo
- Password: XXXXXXXXXXXX (obscured for obvious reasons)
- Driver name: MariaDB
I've spent a lot of time reading documentation and Q&A here and elsewhere, such as: Connection to MySQL database does not work and https://stackoverflow.com/questions/62564439/mysql-mariadb-server-raspberry-pi-remote-access
My Configuration file:
/etc/mysql/mariadb.conf.d/50-server.cnf
contains:
bind-address=0.0.0.0
And running the command: mariadbd --print-defaults
Includes the following output: --bind-address=0.0.0.0, confirming that the configuration setting is being picked up.
Also, sudo netstat -ls contains this result:
| proto | Recv-Q | Send-Q | Local Address | Foreign Address | State |
|---|---|---|---|---|---|
| tcp | 0 | 0 | 0.0.0.0:3306 | 0.0.0.0:* | LISTEN |
I'm quite certain that MariaDB is actually running OK and that I know my own password, and that the database exists, etc. I can run the MariaDB Client on the Pi. The following selected information is from the MariaDB client's "status" command:
Server: MariaDB
Server version: 10.11.6-MariaDB-0+deb12u1 Debian 12
TCP port: 3306
Also, I have deployed a proof-of-concept ASP.NET Core web app on the RPi which runs a simple demo page that extracts data from MariaDB and displays it. I've exposed this via a Cloudflare tunnel and you can see it at: https://mooseware.dev. The text on that page: This is from the database comes from MariaDB.
I'm sure that I can connect (in general) from the Windows PC to the Raspberry Pi. My PC's hosts file contains these lines:
192.168.0.109 tachnitpi
192.168.0.109 tachnitpi.local
Also, I can FTP from the Windows PC to the Raspberry Pi to deploy code.
I've created users for the database that should be able to connect remotely. Using the MariaDB Client, with the SQL statement: select user,host from mysql.user I get these results:
| User | Host |
|---|---|
| moosewaredbo | % |
| mariadbsys | localhost |
| mysql | localhost |
| root | localhost |
From my Windows PC, I can run this ping command and see a connection, so I know the name is resolving:
C:\>ping tachnitpi
Pinging tachnitpi [192.168.0.109] with 32 bytes of data:
Reply from 192.168.0.109: bytes=32 time<1ms TTL=64
Reply from 192.168.0.109: bytes=32 time<1ms TTL=64
Reply from 192.168.0.109: bytes=32 time<1ms TTL=64
Reply from 192.168.0.109: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.0.109:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
The IP address of the Pi is configured to be static IPv4 so that reboots won't break anything.
There is no firewall policy on the Pi that is blocking connections, as far as I can tell (although I am no Linux expert). As noted, MariaDB is listening, and the Pi responds to pings and
The output of the command: sudo iptables -L is as follows:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Lastly, I've checked Windows Firewall on my PC and there are no outbound rules, so I don't think it's anything to do with the PC firewall, specifically.
Any help with figuring this out will be very greatly appreciated! I've been banging my head on this for a long time now. I should say that I'm an experienced application developer on the Microsoft platform, and a real newbie on RPi and Linux in general, so it will probably be something very obvious that I'm missing and just don't know about yet.