# Postgres: Troubleshooting Remote Access

Here's steps to work through, to ensure remote access to a PostgreSQL instance.

#### Check PostgreSQL is Listening on All Interfaces

From a terminal, open the postgresql.conf file, with this:

```bash
sudo nano /etc/postgresql/<version>/main/postgresql.conf
```

<p class="callout info">NOTE: Replace &lt;version&gt; with the version you installed. Will be '16' as of this writing.</p>

Locate the line with 'listen\_addresses' and ensure it is set to listen on all adapters.  
Or, to listen on a specific one for the host.

[![image.png](https://wiki.galaxydump.com/uploads/images/gallery/2025-07/scaled-1680-/VZ70viB6rJkz9B23-image.png)](https://wiki.galaxydump.com/uploads/images/gallery/2025-07/VZ70viB6rJkz9B23-image.png)

It is commented out, by default.  
So, you will need to open up the listener to at least one adapter, or, all, like above.

Save and close the config file, and restart the postgres instance with this:

```bash
sudo systemctl restart postgresql
```

#### Allowed Source Subnets

Open the pg\_hba.conf file, to verify allowed source subnets and protocols, with this:

```bash
sudo nano /etc/postgresql/<version>/main/pg_hba.conf
```

<p class="callout info">NOTE: Same as before, replace &lt;version&gt; with the installed version. '16' as of this writing.</p>

Make sure the allowed sources includes the subnet of your source hosts.

For this, you may need to add lines for each allowed subnet, like this:

```bash
host    all             all             192.168.1.0/24          md5
```

[![image.png](https://wiki.galaxydump.com/uploads/images/gallery/2025-07/scaled-1680-/1O7MBA3AKOw0HTeL-image.png)](https://wiki.galaxydump.com/uploads/images/gallery/2025-07/1O7MBA3AKOw0HTeL-image.png)

The above example allows access from several subnets.

Save and close the config.

And, reload it, with this:

```bash
sudo systemctl reload postgresql
```

#### Ensure Correct Listening Port

Run this on the Postgres host, to see what ports the database engine is listening on:

```bash
sudo ss -tnlp | grep 5432
```

You will see something like this for a default install:

[![image.png](https://wiki.galaxydump.com/uploads/images/gallery/2025-07/scaled-1680-/l68aoLsTciwmbcxS-image.png)](https://wiki.galaxydump.com/uploads/images/gallery/2025-07/l68aoLsTciwmbcxS-image.png)

<p class="callout info">NOTE: By default, the engine listens on 5432.</p>

#### Firewall Ingress Rule

Make sure the host firewall allows incoming connections, with this:

```bash
sudo ufw allow 5432/tcp
```

#### Test from Remote Client

Now, verify connectivity from your remote client.