Live Chat
True
FAQs
Technical

Configure PostgreSQL to allow remote connection on ubuntu

#Configuring postgresql.conf


#on ubuntu you can ask ssh or terminal about postgresql.conf    bath by the following command


sudo -u postgres psql -c 'SHOW config_file'


# you will see the result like the following as example bath

#/etc/postgresql/10/main/postgresql.conf

#edit file by any editor tool like vim or nano command as like the foolowing


nano /etc/postgresql/10/main/postgresql.conf

#replace line  #listen_addresses = 'localhost'
remove # and replace local host by * like the following that mean open to any ip connection or replace * by your IP that you want to allow connection 

listen_addresses = '*'


#Configuring pg_hba.conf  (bath for is the same bath for postgresql.conf but replace postgresql.conf from bath by pg_hba.conf like the following

nano /etc/postgresql/10/main/pg_hba.conf
# add the following lines to allow for any ip to connect


host    all             all              0.0.0.0/0                       md5

host    all             all              ::/0                            md5


#or add the following specific ip address only like 192.168.1.2


host all all 192.168.1.2/32 md5

host    all             all             ::/0            md5



#set password for postgres user (without this step you can't register server to login by pgadmin4 on postgresql)


su - postgres


psql


\password postgres


#wirte your password like postgres

#quite


\q


#return to your root user again


su root



#save file and restart postgresql service by the following command

sudo service postgresql restart



Was this article helpful?

FAQ HOME

To install this Web App in your iPhone/iPad press and then Add to Home Screen.