I installed PostgreSQL on my local server (Ubuntu) with IP 192.168.1.10. Now, I'm trying to access the database from my client machine (Ubuntu) with IP 192.168.1.11 with pgAdmin.
I know I have to make changes in postgresql.conf and pg_hba.conf to allow the client to connect. Could you please guide me?
This question is related to
postgresql
pgadmin
I didn't have to change my prostgresql.conf file but, i did have to do the following based on my psql via command line was connecting and pgAdmin not connecting on RDS with AWS.
I did have my RDS set to Publicly Accessible. I made sure my ACL and security groups were wide open and still problem so, I did the following:
sudo find . -name *.conf
then sudo nano ./data/pg_hba.conf
then added to top of directives in pg_hba.conf file host all all 0.0.0.0/0 md5
and pgAdmin automatically logged me in.
This also worked in pg_hba.conf file
host all all md5
without any IP address and this also worked with my IP address host all all <myip>/32 md5
As a side note, my RDS was in my default VPC. I had an identical RDS instance in my non-default VPC with identical security group, ACL and security group settings to my default VPC and I could not get it to work. Not sure why but, that's for another day.
In linux terminal try this:
sudo service postgresql start
: to start the serversudo service postgresql stop
: to stop thee serversudo service postgresql status
: to check server statusFor redhat linux
sudo vi /var/lib/pgsql9/data/postgresql.conf
pgsql9 is the folder for the postgres version installed, might be different for others
changed listen_addresses = '*' from listen_addresses = ‘localhost’ and then
sudo /etc/init.d/postgresql stop
sudo /etc/init.d/postgresql start
Connecting to PostgreSQL via SSH Tunneling
In the event that you don't want to open port 5432 to any traffic, or you don't want to configure PostgreSQL to listen to any remote traffic, you can use SSH Tunneling to make a remote connection to the PostgreSQL instance. Here's how:
If you're using PostgreSQL 8 or above, you may need to modify the listen_addresses
setting in /etc/postgresql/8.4/main/postgresql.conf
.
Try adding the line:
listen_addresses = *
which will tell PostgreSQL to listen for connections on all network interfaces.
If not explicitly set, this setting defaults to localhost
which means it will only accept connections from the same machine.
Check your firewall. When you disable it, then you can connect. If you want/can't disable the firewall, add a rule for your remote connection.
Source: Stackoverflow.com