Reputation: 847
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?
Upvotes: 56
Views: 120086
Reputation: 612
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:
Upvotes: 1
Reputation: 21
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 statusUpvotes: 2
Reputation:
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.
Upvotes: 0
Reputation: 1321
For 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
Upvotes: 0
Reputation: 101
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.
Upvotes: 1
Reputation: 8807
It is actually a 3 step process to connect to a PostgreSQL server remotely through pgAdmin3.
Note: I use Ubuntu 11.04 and PostgreSQL 8.4.
You have to make PostgreSQL listening for remote incoming TCP connections because the default settings allow to listen only for connections on the loopback interface. To be able to reach the server remotely you have to add the following line into the file /etc/postgresql/8.4/main/postgresql.conf:
listen_addresses = '*'
PostgreSQL by default refuses all connections it receives from any remote address, you have to relax these rules by adding this line to /etc/postgresql/8.4/main/pg_hba.conf:
host all all 0.0.0.0/0 md5
This is an access control rule that let anybody login in from any address if he can provide a valid password (the md5 keyword). You can use needed network/mask instead of 0.0.0.0/0 .
When you have applied these modifications to your configuration files you need to restart PostgreSQL server. Now it is possible to login to your server remotely, using the username and password.
Upvotes: 118
Reputation: 29587
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.
Upvotes: 8