IntelliJ IDEA Test Connection fails for a PostgreSQL data source
Test Connection in the data source properties reports a failureShort answer
When Test Connection fails, work from the bottom up. First confirm the host and port answer outside the IDE, then confirm the driver files are downloaded, then the SSL or SSH settings. IntelliJ's own guide lists these checks, in that order, with the Windows temp path as a rare cause.
Fix it fast
1Find out which cause you have
Check from a terminal that the host and port accept connections. If this fails, the problem is the server or network, not IntelliJ.
pg_isready -h localhost -p 54322Match what you see, then jump to its fix
- 1
A 'Download missing driver files' link shows under the connection settingsDriver files are not downloadedFix - 2
pg_isready says no response, or the port in the URL differs from the server'sHost, port or credentials do not match the serverFix - 3
Terminal works only through a tunnel, or the server insists on SSLSSL or an SSH tunnel is required, or set up wronglyFix - 4
Windows user name with accents; all other checks passThe Windows temp path has non-ASCII charactersFix
- 1
What does the error look like?
Test Connection in the data source properties reports a failureConnection to localhost:5432 refused.
Cause 1 of 4
Driver files are not downloaded
1Check
The data source cannot work without its JDBC driver. IntelliJ shows the link at the bottom of the connection settings when files are missing.
echo "Open Data Source Properties and look for the link under the form"2Fix
Click Download missing driver files, wait for it to finish, then test again. If a different driver version is needed for your server, pick it in the Drivers settings.
echo "Database tool window > Data Source Properties > Download missing driver files"3Verify
Test Connection now reports success.
echo "Click Test Connection"Confirmed by jetbrains.com
Cause 2 of 4
Host, port or credentials do not match the server
1Check
The default PostgreSQL port is 5432 but real servers often differ. For a local database use localhost or 127.0.0.1. The URL format is jdbc:postgresql://host:port/database.
sudo ss -ltnp | grep postgres
pg_isready -h 127.0.0.1 -p 54322Fix
Enter the real host, port, user, password and database. With a Docker container, publish the port with -p and use the published one in the IDE.
jdbc:postgresql://127.0.0.1:5432/mydb3Verify
Test Connection succeeds.
psql "postgresql://myuser@127.0.0.1:5432/mydb" -c "SELECT 1"Confirmed by jetbrains.com
Cause 3 of 4
SSL or an SSH tunnel is required, or set up wrongly
1Check
The SSH/SSL tab holds the CA, client certificate and key files; PEM files are recommended. A self-signed certificate can fail with a newer driver.
openssl s_client -starttls postgres -connect db.example.com:5432 </dev/null | head2Fix
Turn SSL on or off to match the server, load the PEM files, or use the IDE's SSH tunnel. As a stopgap for self-signed certificates, the guide suggests temporarily using an older driver.
echo "Data Source Properties > SSH/SSL tab"3Verify
Test Connection succeeds with the SSH/SSL tab settings.
echo "Click Test Connection"Confirmed by jetbrains.com
Cause 4 of 4
The Windows temp path has non-ASCII characters
1Check
The guide says the temp directory path must not contain non-ASCII characters.
echo %TEMP%2Fix
Point Java at a clean temp folder in idea.vmoptions, then restart the IDE.
-Djava.io.tmpdir=C:\temp3Verify
Test Connection works after restart.
echo "Click Test Connection"Confirmed by jetbrains.com
How do I stop it coming back?
- Keep the port in a project README or .env so the IDE and the app use the same one.
- Use the same PostgreSQL JDBC driver family the app uses, to catch SSL differences early.
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
Cannot connect to PostgreSQL on port 5432 from another machine
FATAL: no pg_hba.conf entry for host "198.51.100.7", user "app", database "appdb"
Two settings guard remote access.
3 causes, each with a fixDatabases
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
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 fixDatabases
manage.py test stops with 'permission denied to create database' on PostgreSQL
django.db.utils.ProgrammingError: permission denied to create database
Django creates a separate database called test_ plus your database name, using the DATABASES USER.
2 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
pg_dump refuses to run: server version is newer than pg_dump
pg_dump: detail: server version: 17.2; pg_dump version: 14.13
pg_dump will not dump a server whose major version is newer than its own.
3 causes, each with a fix