Skip to content
Guide · DataGrip

How to Connect DataGrip to PostgreSQL

A DataGrip PostgreSQL connection is a data source: host, port, user, password and database, plus optional SSL and SSH settings. This guide follows JetBrains' documented steps for DataGrip 2026.2 and explains the PostgreSQL authentication errors that usually stop the first connection.

Steps and facts checked 8 October 2026 against the vendor's official documentation. Versions covered: DataGrip 2026.2, PostgreSQL 9.1 to 18 (DataGrip's documented range), PostgreSQL JDBC driver 42.7.3 bundled. Next review due April 2027. Menus, shortcuts and prices change between releases; check the vendor's documentation for your version.
Short answer
  • 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.
How we know: Research-based: the steps, options and error messages were checked against the DataGrip documentation and the PostgreSQL documentation on 8 October 2026. We have not made this connection for the guide; dialog labels are quoted from JetBrains' documentation and may differ slightly between versions.

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

  1. 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.)
  2. On the General tab, leave the default driver and choose a Connection type: default (host, port, database and URL) or URL only.
  3. Enter the Host and Port. The default PostgreSQL port is 5432, but check the real value with whoever runs the server.
  4. Choose an Authentication method: User & Password, pgpass (read the password from a .pgpass file in your home directory) or No auth.
  5. Enter the User, Password and Database. DataGrip builds the JDBC URL from these fields.
  6. Click Test Connection at the bottom of the connection details.
  7. Optionally, open the Schemas tab and select other databases and schemas to introspect; by default only the default database and schema are loaded.
  8. 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.

PostgreSQL JDBC URL format and example from the DataGrip documentation
jdbc:postgresql://<host_address>:<port_number>/<database_name>
jdbc:postgresql://127.0.0.1:5432/myDatabase
Line format of a .pgpass file (PostgreSQL documentation)
hostname:port:database:username:password

Connect 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:

  1. On the SSH/SSL tab, select Use SSH tunnel and click Add SSH configuration.
  2. In SSH Configurations, click Add and enter the SSH server's Host, Port and Username.
  3. Pick an Authentication type: Password, Key pair (OpenSSH or PuTTY), or OpenSSH config and authentication agent.
  4. Click Test Connection for the SSH configuration, then OK.
  5. 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.

Messages from the PostgreSQL documentation and what to check
MessageWhat it meansWhat 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 existThe role name is wrong.Check the User field.
FATAL: database "..." does not existThe database name is wrong.Check the Database field; if it is empty PostgreSQL uses the user name.
Connection refused or timeoutNothing 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

Checked 8 October 2026.

How we research tool guides: our editorial method. CodeWithSQL earns nothing from the vendors mentioned.

Still choosing a SQL client?

Read the full reviews, or compare tools side by side.