-> After the set up is completed i.e. both installation and initdb the database is accessable from the local host alone. If we want to access the server from other machines we need to modify the configuration files.
-> These files will be available in data directory.
step1: Update in postgresql.conf file
-> First go to the data directory. Then open the postgresql.conf file using the cmd.
cmd:nano postgresql.conf
-> Edit this line below in the file by defalut its locahost change it to ‘*’ and remove the comment.
listener_address =’*’
-> If we wnat to run the server on anyother port than 5432 then change this line also.
-> Then CTRL+o to write out then press enter to save the changes then CTRL+x to exit.
Step2: Update in pg_hba.conf file
-> In this file we need to specify the IP range to access from the other system with in the network.
-> First go to the data directory. Then open the pg_hba.conf file using the cmd.
cmd:nano pg_hba_conf
-> Add the highlighted lines as mentioned in the image.
-> Then CTRL+o to write out then press enter to save the changes then CTRL+x to exit.
-> Now we will be able to access the server from the given IP’s in the pg_hba.conf file.
Note:
For any update in configuration files we need to make sure that we need to restrat the server or stop and start the server.