How to Fix “Received fatal alert: unexpected_message” in DBeaver While Connecting to PostgreSQL
Introduction
If you’re trying to connect to a PostgreSQL database using DBeaver and you see this error:
Don’t worry — this is a very common issue, and it’s usually caused by an SSL configuration mismatch between DBeaver and PostgreSQL.
In this guide, I’ll explain:
- Why this error happens
- What it actually means
- And how to fix it in under 2 minutes
Why This Error Happens
The error:
Received fatal alert: unexpected_messageis a TLS/SSL handshake failure.
This happens when:
- DBeaver tries to connect using SSL
- But PostgreSQL server is not configured for SSL
- Or the SSL mode does not match the server configuration
In simple words:
The client and server are speaking different security protocols.
Quick Fix (Works in Most Local Setups)
If you’re connecting to a local PostgreSQL installation, SSL is usually disabled by default.
Step-by-step Fix:
- Open DBeaver
- Right-click your connection → Edit Connection
- Go to the SSL tab
- Change:
SSL Mode = disable- Click Test Connection
- Click Finish
That’s it 🎉
Why Disabling SSL Works
In most local setups:
- PostgreSQL runs with:
ssl = off- inside
postgresql.conf - But DBeaver may default to:
- SSL Mode = require
This mismatch causes the TLS handshake to fail.
When you set SSL Mode to disable, both sides agree — and the connection succeeds.
What If You’re Connecting to a Remote Server?
If you’re connecting to:
- Cloud database
- Company server
- Production database
Then you should NOT disable SSL.
Instead, try:
SSL Mode = requireor
SSL Mode = preferCheck with your database administrator for the correct SSL configuration.
Other Possible Causes
Although SSL mismatch is the most common reason, this error can also occur due to:
- Wrong port (PostgreSQL default is 5432)
- PostgreSQL service not running
- Corrupted JDBC driver
- Connecting to a non-PostgreSQL service
Driver used by DBeaver:
PostgreSQL JDBC Driver
If needed, update the driver from:
Edit Connection → Driver Settings → Download/Update.
Final Thoughts
If you encounter:
Don’t panic.
In 90% of local development environments, simply:
Set SSL Mode to disable
And your connection will work instantly.
If this helped you, consider sharing it with other developers who might run into the same issue.
Happy querying 🚀
