Post

Configuring PostgreSQL Connection

Configuring PostgreSQL Connection

Step 1: Modify pg_hba.conf

To allow connections to your PostgreSQL database, you need to update the pg_hba.conf file.

File Location:

1
/var/lib/postgresql/data/pg_hba.conf

Add the Following Entry:

This is docker network (bridge)

1
host    all             all             172.17.0.0/32            trust

If you are unsure of the IP address, you can use:

1
host    all             all             0.0.0.0/32            trust

This will allow connections from any IP address.

Step 2: Restart PostgreSQL

After making changes, restart PostgreSQL to apply the new configuration:

1
sudo systemctl restart postgresql

Or, if you are using Docker:

1
docker restart <postgres_container_name>

Step 3: Verify Connection

You can test the connection using the following command:

1
psql -h <your_postgres_host> -U <your_username> -d <your_database>

This should now allow connections based on your updated settings. postgres_connection_guide.md

This post is licensed under CC BY 4.0 by the author.