Setting postgres for remote access
Created at 2018-02-03 Updated at 2025-09-05 - 1 min. read
Let’s setup postgres which is accessible from remote connection
- Installation - 1 
 2- sudo apt-get update 
 sudo apt-get install postgresql postgresql-contrib
- Switch over to the - postgresaccount on your server by typing- 1 - sudo -i -u postgres 
- Creating new user is postgres - 1 - createuser --interactive 
- Configuring postgresql.conf 
 In order to fix this issue we need to find postgresql.conf. In different systems it is located at different place. I usually search for it.- 1 
 2- find \ -name "postgresql.conf" 
 /var/lib/pgsql/9.6/data/postgresql.conf- Open postgresql.conf file and replace line - 1 - listen_addresses = '*' 
- Now restart postgresql server. - 1 - sudo service postgres restart 
- Configuring pg_hba.conf - 1 
 2
 3- host all all 0.0.0.0/0 md5 
 host all all ::/0 md5
- Again restart the postgres - sudo service postgres restart
