Setting postgres for remote access
Created at 2018-02-03 Updated at 2024-11-07 - 1 min. read
Let’s setup postgres which is accessible from remote connection
- Installation
1
2sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
- Switch over to the
postgres
account on your server by typing1
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
2find \ -name "postgresql.conf"
/var/lib/pgsql/9.6/data/postgresql.confOpen postgresql.conf file and replace line
1
listen_addresses = '*'
Now restart postgresql server.
1
sudo service postgres restart
Configuring pg_hba.conf
1
2host all all 0.0.0.0/0 md5
host all all ::/0 md5Again restart the postgres
sudo service postgres restart