> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/database/postgresql/enable-remote-access-for-postgresql.md).

# Enable remote access for PostgreSQL

By default, the PostgreSQL, server listens only on the local interface <mark style="color:orange;">`127.0.0.1`</mark>.

If you want to connect to the PostgreSQL server from remote locations, you need to set the server to listen on the public interface and edit the configuration to accept remote connections.

1. Open the configuration file <mark style="color:orange;">`postgresql.conf`</mark> and add <mark style="color:orange;">`listen_addresses = '*' in the CONNECTIONS AND AUTHENTICATION`</mark> section. This instruct the server to listen on all network interfaces.

```bash
sudo vim /etc/postgresql/11/main/postgresql.conf
```

```bash
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'     # what IP address(es) to listen on;
```

1. Save the file and restart the PostgreSQL service for changes to take effect:

```bash
sudo systemctl restart postgresql
```

Verify changes:

```bash
ss -nlt | grep 5432
```

```bash
LISTEN   0         128                 0.0.0.0:5432             0.0.0.0:*
LISTEN   0         128                    [::]:5432                [::]:*
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.arkannis.net/database/postgresql/enable-remote-access-for-postgresql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
