I followed the steps in this tutorial to set up nodeJS web server in ubuntu-18-04.
Now what I should take into account while following this tutorial to set up postgres on another droplet in order to be able to connect to it from the other droplet?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
You would need to configure your PostgreSQL service to allow remote connections.
You can do that by following the steps here:
Update the postgresql.conf file:
First, find the file with the following command:
sudo find / -name "postgresql.conf"
Once you find the file, open it with your favorite text editor and find this line here:
listen_addresses = 'localhost'
And change it to:
listen_addresses = '*'
With that change, the service will no longer listen only on localhost:5432 but on 0.0.0.0:5432 and will be accessible from the outside world and not only the Droplet itself.
Update the pg_hba.conf file
Again in order to find the file you can use this command here:
sudo find / -name "pg_hba.conf"
Then open the file and add the following entry:
all all YOUR_IP_ADDRESS/32 trust
That way all IP addresses will be allowed to access the service.
Hi there,
You would need to configure your PostgreSQL service to allow remote connections.
You can do that by following the steps here:
postgresql.conf
file:First, find the file with the following command:
Once you find the file, open it with your favorite text editor and find this line here:
And change it to:
With that change, the service will no longer listen only on
localhost:5432
but on0.0.0.0:5432
and will be accessible from the outside world and not only the Droplet itself.pg_hba.conf
fileAgain in order to find the file you can use this command here:
Then open the file and add the following entry:
That way all IP addresses will be allowed to access the service.
Finally, restart the PostgreSQL service.
Hope that this helps! Regards. Bobby