- Create the connection with File | New | Data Source | PostgreSQL, fill in host, port (5432 by default), user, password and database, then click Test Connection.
- DataGrip 2026.2 bundles the PostgreSQL JDBC driver; DataGrip documents support for PostgreSQL 9.1 to 18.
- SSL and SSH tunnels are both set on the SSH/SSL tab of the same dialog.
- Most first-time failures are server-side: a missing pg_hba.conf entry, a wrong password, or a database that does not exist.
Before you start: what a DataGrip PostgreSQL connection needs
To set up a DataGrip PostgreSQL connection you need a running PostgreSQL server and five details: host name or IP address, port, database name, user name and password. DataGrip's documentation assumes the server is already installed and reachable, so if PostgreSQL runs on your own machine, install and start it first.
DataGrip documents support for PostgreSQL versions 9.1 to 18. You do not need to download a driver separately: since DataGrip 2026.2 the PostgreSQL JDBC driver (version 42.7.3) is bundled with the IDE. If a driver is still missing, the dialog shows a Download missing driver files link.
Create the PostgreSQL data source step by step
- In the main menu, go to File | New | Data Source and select PostgreSQL. (Alternatively, click New on the Database Explorer toolbar and choose Data Source | PostgreSQL.)
- On the General tab, leave the default driver and choose a Connection type: default (host, port, database and URL) or URL only.
- Enter the Host and Port. The default PostgreSQL port is 5432, but check the real value with whoever runs the server.
- Choose an Authentication method: User & Password, pgpass (read the password from a
.pgpassfile in your home directory) or No auth. - Enter the User, Password and Database. DataGrip builds the JDBC URL from these fields.
- Click Test Connection at the bottom of the connection details.
- Optionally, open the Schemas tab and select other databases and schemas to introspect; by default only the default database and schema are loaded.
- Click OK. The data source appears in the Database Explorer. Select it and press F4 to open a query console.
The URL only type uses the JDBC URL exactly as typed, credentials included. JetBrains notes that in this mode the URL is stored in plain text and appears in the IDE log, so prefer the default type when the URL would contain a password.
jdbc:postgresql://<host_address>:<port_number>/<database_name>
jdbc:postgresql://127.0.0.1:5432/myDatabasehostname:port:database:username:passwordConnect with SSL
Managed PostgreSQL services usually require SSL. Open the data source properties (File | Data Sources, or Ctrl+Alt+Shift+S on Windows), go to the SSH/SSL tab and select Use SSL. Then:
- Point CA file at the provider's CA certificate, or leave the certificate fields empty and tick Use truststore (IDE, Java or system certificates).
- Add a Client certificate file and Client key file only if the server requires client certificates.
- Choose a Mode: Require, Verify CA (also checks the certificate chain) or Full Verification (also checks that the host name matches the certificate).
JetBrains recommends PEM certificates. With self-signed certificates, the documentation warns that the latest JDBC driver can reject the certificate chain.
Connect through an SSH tunnel
If PostgreSQL sits on a private network behind a bastion host, let DataGrip create the tunnel:
- On the SSH/SSL tab, select Use SSH tunnel and click Add SSH configuration.
- In SSH Configurations, click Add and enter the SSH server's Host, Port and Username.
- Pick an Authentication type: Password, Key pair (OpenSSH or PuTTY), or OpenSSH config and authentication agent.
- Click Test Connection for the SSH configuration, then OK.
- Leave Local port empty to let DataGrip choose one, then test the database connection.
On the General tab, keep the database host as the SSH server sees it (often localhost), because the host name is resolved on the SSH server. SSH configurations are shared across the project's data sources unless you tick Visible only for this project.
Common PostgreSQL connection errors
DataGrip's own troubleshooting page adds two checks: make sure the JDBC driver version suits your server, and on Windows make sure the temp directory path contains only ASCII characters.
| Message | What it means | What to check |
|---|---|---|
FATAL: no pg_hba.conf entry for host ... | You reached the server, but no rule in pg_hba.conf matches your host, user and database. | Ask the administrator to add a matching rule, or connect through SSH so you arrive from an allowed host. |
FATAL: password authentication failed for user ... | The server is willing to talk but the password did not pass the configured method. | Re-enter the password, or check the .pgpass line if you chose pgpass. |
FATAL: user "..." does not exist | The role name is wrong. | Check the User field. |
FATAL: database "..." does not exist | The database name is wrong. | Check the Database field; if it is empty PostgreSQL uses the user name. |
| Connection refused or timeout | Nothing answered on that host and port. | Follow DataGrip's checklist: ping the host, test the port with telnet, confirm 5432 or the real port. |
Frequently asked questions
What port does DataGrip use for PostgreSQL?
The DataGrip default is 5432, PostgreSQL's standard port. Use whatever port your server or provider actually listens on.
Do I need to download a PostgreSQL driver for DataGrip?
Not in DataGrip 2026.2, which bundles PostgreSQL JDBC driver 42.7.3. Older versions show a Download missing driver files link in the data source dialog.
Why do I see only one database in DataGrip?
By default only the default database and schema are introspected. Select more on the Schemas tab, or click the N of M button next to the data source in the Database Explorer.
How do I set the DataGrip PostgreSQL SSL mode?
On the SSH/SSL tab, select Use SSL and choose Require, Verify CA or Full Verification in the Mode list.
Can DataGrip use my .pgpass file?
Yes. Choose pgpass in the Authentication list. Each line of the file has the form hostname:port:database:username:password.
Sources
- DataGrip documentation: PostgreSQL
- DataGrip documentation: Configure SSH and SSL
- DataGrip documentation: Cannot connect to a database
- JetBrains: What's New in DataGrip 2026.2
- PostgreSQL documentation: Authentication Problems
- PostgreSQL documentation: The Password File
Checked 8 October 2026.
How we research tool guides: our editorial method. CodeWithSQL earns nothing from the vendors mentioned.