Troubleshooting Postgres Connection Issues

PostgreSQL
database
Published

January 29, 2026

Abstract

How to troubleshoot Postgres connectivity issues for Posit products

Description

Posit professional products can be configured to use PostgreSQL. This article discusses common steps required to confirm database connectivity.

Solution

Confirm inbound firewall rules

Ensure that you have allowed the necessary inbound firewall rules for your PostgreSQL server. By default, PostgreSQL listens on port 5432.

Allow access to the database

By default, a standard PostgreSQL installation will block all inbound connections at the operating system, regardless of your firewall settings. You will need to allow access by modifying your pg_hba.conf configuration file. You will need to add a line that looks something like this:

pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD          
  host  all             all             127.0.0.1/32            trust

This allows all users access to all databases on the localhost. Different organizations will have different security protocols, so it’s best to reach out to your organization’s security team to ensure that you have implemented the correct settings. More information on the configuration options can be found here:

https://www.postgresql.org/docs/current/auth-pg-hba-conf.html

Then, restart PostgreSQL for these changes to take effect.

Verify database access

Before making any configuration changes to Posit products, verify access from your Posit servers command line, using the pg_isready utility as below:

PostgresSQL Docs - pg_isready

Terminal
pg_isready -d <db_name> -h <host_name> -p <port_number> -U <db_user>                    

Exit Status

pg_isready returns the following to the shell:

  • 0 - if the server is accepting connections normally,
  • 1 - if the server is rejecting connections (for example during startup),
  • 2 - if there was no response to the connection attempt, and
  • 3 - if no attempt was made (for example due to invalid parameters).

According to the pg_isready manual:

It is not necessary to supply correct user name, password, or database name values to obtain the server status; however, if incorrect values are provided, the server will log a failed connection attempt.

Connect Posit product to database

Once you’ve gotten confirmation from pg_isready, you can begin connecting your Posit product to the database. Our documentation can be found here: