pgAdmin cannot connect to the PostgreSQL server: timeout expired
Timeout expiredShort answer
Timeout expired means pgAdmin sent a connection request and heard nothing back within its limit. Test the host and port with pg_isready first. If it gets no response, the server is not listening on that address or something blocks the path. If it answers, raise the connection timeout or use an SSH tunnel.
Fix it fast
1Find out which cause you have
From the machine that runs pgAdmin, ask the server whether it answers on that host and port. Exit code 2 means no response.
pg_isready -h db.example.com -p 5432 -t 5 echo $?2Match what you see, then jump to its fix
- 1
pg_isready returns 2 from another machine but 0 on the server itselfThe server listens only on localhostFix - 2
pg_isready works with the right address but pgAdmin uses another oneThe host or port in the pgAdmin server entry is wrongFix - 3
pg_isready returns 2 from your laptop, but works from a jump hostThe database is on a private networkFix - 4
pg_isready returns 0 but pgAdmin still times outThe server is slow to answer and pgAdmin gives up at 10 secondsFix
- 1
What does the error look like?
Timeout expired
Cause 1 of 4
The server listens only on localhost
1Check
The default listen_addresses is localhost, which allows only local loopback connections. A remote pgAdmin never gets an answer.
psql -c "SHOW listen_addresses;"
sudo ss -ltn | grep 54322Fix
Set listen_addresses to the interface you need (or '*' for all) in postgresql.conf and restart. The setting is read at server start only.
# postgresql.conf
listen_addresses = '*'
# then restart
sudo systemctl restart postgresql3Verify
pg_isready now returns 0 from the pgAdmin machine.
pg_isready -h db.example.com -p 5432Confirmed by postgresql.org
Cause 2 of 4
The host or port in the pgAdmin server entry is wrong
1Check
Open the server's Properties, then the Connection tab, and compare host name and port with what pg_isready accepted. The default port is 5432.
pg_isready -h <host from pgAdmin> -p <port from pgAdmin>2Fix
Correct the Host name/address and Port on the Connection tab and save.
# pgAdmin: right-click server > Properties > Connection
# Host name/address: db.example.com
# Port: 54323Verify
Connect again and the server tree opens.
pg_isready -h db.example.com -p 5432Confirmed by pgadmin.org
Cause 3 of 4
The database is on a private network
1Check
If the server is reachable only from inside a network, pgAdmin cannot reach it directly.
pg_isready -h 10.0.0.5 -p 5432 -t 52Fix
Use the SSH Tunnel tab: enable Use SSH tunneling and enter the tunnel host, port and user. Set the Connection host to the address the SSH host sees.
# pgAdmin > Properties > SSH Tunnel
# Use SSH tunneling: Yes
# Tunnel host / Tunnel port / Username3Verify
Connect and the timeout error is gone.
pg_isready -h db.example.com -p 5432Confirmed by pgadmin.org
Cause 4 of 4
The server is slow to answer and pgAdmin gives up at 10 seconds
1Check
pgAdmin's connection timeout is 10 seconds by default. A server that is starting or far away can exceed it.
pg_isready -h db.example.com -p 5432 -t 302Fix
On the Parameters tab raise the Connection timeout. The docs advise against anything under 2 seconds.
# pgAdmin > Properties > Parameters
# Connection timeout: 303Verify
Reconnect and watch the server tree load.
pg_isready -h db.example.com -p 5432Confirmed by pgadmin.org
How do I stop it coming back?
- Keep one saved pgAdmin entry per server and check host and port after any server move.
- Run pg_isready in monitoring so a down server is found before pgAdmin shows a timeout.
- Reach private databases through SSH tunnels, not by opening the port to everyone.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Databases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
DBeaver cannot download the PostgreSQL driver from Maven
The PostgreSQL driver files are missing and the download does not complete
DBeaver downloads the PostgreSQL JDBC driver from a Maven repository the first time you connect.
3 causes, each with a fixDatabases
python manage.py migrate finishes but the tables for my app are missing
relation "myapp_book" does not exist
migrate only applies migration files that exist.
3 causes, each with a fixDatabases
Django save fails on PostgreSQL: null value in a column violates a not-null constraint
django.db.utils.IntegrityError: null value in column "price" of relation "shop_product" violates not-null constraint
A model field is NOT NULL in the database unless it has null=True.
3 causes, each with a fixDatabases
Django migration on PostgreSQL stops with 'pending trigger events'
django.db.utils.OperationalError: cannot ALTER TABLE "mytable" because it has pending trigger events
PostgreSQL runs a Django migration in one transaction.
2 causes, each with a fixDatabases
Django cannot connect to PostgreSQL: connection refused on port 5432, locally or in Docker
Is the server running on that host and accepting TCP/IP connections?
Connection refused means nothing accepted the connection at the host and port Django used.
4 causes, each with a fix