Skip to content

Fix DBeaver Connection Refused – Cannot Connect to Database

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about Fix DBeaver Connection Refused. We cover key concepts, practical examples, and best practices.

You open DBeaver, click New Database Connection, fill in host, port, and credentials β€” and get "Connection refused: connect". The database server is running, SSH works, but DBeaver won't talk to it.

Wrong ❌

# On the DB server β€” common mistake: binding only to localhost
netstat -an | grep 3306
tcp  0  0  127.0.0.1:3306  0.0.0.0:*  LISTEN

Your MySQL only listens on loopback. DBeaver connects from a remote machine, so the kernel rejects the TCP handshake immediately.

You try ping <server> from the DBeaver host β€” success. But the port is invisible.

For MySQL:

# /etc/mysql/my.cnf
[mysqld]
bind-address = 0.0.0.0
# or a specific network interface: 192.168.1.50

For PostgreSQL:

# postgresql.conf
listen_addresses = '*'

For both: Verify the port is open and listening on the right interface:

ss -tlnp | grep -E '3306|5432'
tcp   LISTEN  0  128  0.0.0.0:3306  0.0.0.0:*   users:(("mysqld",pid=1234))
tcp   LISTEN  0  128  0.0.0.0:5432  0.0.0.0:*   users:(("postgres",pid=5678))

Also check the firewall:

sudo ufw allow 3306/tcp
# or for PostgreSQL:
sudo ufw allow 5432/tcp

In DBeaver, test the connection with Test Connection β€” it should show:

Connected
Server: MySQL 8.0.33
Driver: MySQL 8.x
Ping: 2 ms

Root Cause

Databases bind to localhost by default for security. DBeaver runs on a different host, so the OS TCP stack rightfully refuses the connection β€” nothing is listening on the external interface.

Prevention

  • After provisioning a database, check binding with ss -tlnp before opening DBeaver.
  • Restrict access with a firewall instead of relying on the bind address alone.
  • Use SSH tunnels for production databases β€” never expose ports to the internet.
  • Document connection strings in a shared team vault (DBeaver supports .dbeaver/data-sources.json).

Common Mistakes with connection refused

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world DBEAVER code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

**Q: I changed bind-address but still get refused β€” what else?**

A: Restart the database service. Some distributions have skip-networking or skip-external-locking enabled.

**Q: Does DBeaver support SSH tunnels?**

A: Yes β€” in the connection settings, go to SSH tab, enable Use SSH tunnel, and provide the jump‑host credentials.

**Q: The port shows LISTEN but DBeaver still fails β€” why?**

A: A local firewall (iptables, nftables, Windows Defender) may be blocking inbound connections even though the process is listening.

**Q: Can I test with a tool other than DBeaver?**

A: telnet <host> <port> or nc -zv <host> <port> quickly reveals whether the port is reachable.


For deeper database connectivity labs, check the DodaTech DBeaver Mastery course.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro