Thread: Remote connection shows localhost databases
I am trying to connect to a workstation running postgres from another computer on the network. I have postgres installed on both machines. When I go to connect to the workstation, everything appears to happen correctly, however, the server connection shows the databases on the localhost, not the workstation to which I am trying to connect. I had this working at some point, but now I can't seem to get to the databases on the workstation. Both are on port 5432. Any ideas? Thanks... Jeff
On 15/09/11 17:30, Jeff Adams wrote: > I am trying to connect to a workstation running postgres from another > computer on the network. How are you connecting? PgAdmin, psql, Perl script? What is the hostname you are using on the local machine and are you sure it is for the remote machine? -- Richard Huxton Archonet Ltd
[sorry for the duplicate Richard] Thanks for the response Richard. I have tried to connect via pgAdminIII. When I try to connect to the remote machine, I enter \\<server>\<ip_address> into the host name field. What I found was it didn't matter what I entered into the hostname field (I put in random strings to test), it always brought up the databases on the localhost.... Jeffrey D. Adams National Marine Fisheries Service Office of Protected Resources Marine Mammal & Sea Turtle Conservation Division 1315 East West Hwy Building SSMC3 Silver Spring, MD 20910-3282 phone: (301) 427-8434 fax: (301) 713-0376 email: Jeff.Adams@noaa.gov -----Original Message----- From: Richard Huxton [mailto:dev@archonet.com] Sent: Thursday, September 15, 2011 2:50 PM To: Jeff Adams Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Remote connection shows localhost databases On 15/09/11 17:30, Jeff Adams wrote: > I am trying to connect to a workstation running postgres from another > computer on the network. How are you connecting? PgAdmin, psql, Perl script? What is the hostname you are using on the local machine and are you sure it is for the remote machine? -- Richard Huxton Archonet Ltd
On Thu, 2011-09-15 at 15:30 -0400, Jeff Adams wrote: > [sorry for the duplicate Richard] > > Thanks for the response Richard. I have tried to connect via pgAdminIII. > When I try to connect to the remote machine, I enter \\<server>\<ip_address> > into the host name field. What I found was it didn't matter what I entered > into the hostname field (I put in random strings to test), it always brought > up the databases on the localhost.... > In pgAdmin, you have a Name field (which is a description, so free text), and you have a Host field. The host field should contain the socket complete path, or the host name, or the ip address. With this, you're able to connect to any PostgreSQL server, as long as their pg_hba.conf file allows it. -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com
On 15/09/11 22:40, Guillaume Lelarge wrote: > On Thu, 2011-09-15 at 15:30 -0400, Jeff Adams wrote: >> >> When I try to connect to the remote machine, I enter \\<server>\<ip_address> >> into the host name field. > >The host field should contain the > socket complete path, or the host name, or the ip address. As Guillaume says - try just the IP address to start with. What you've been trying is sort-of a Windows networking path. Odd that pgAdmin doesn't give an error though. If you were using psql you'd type something like: psql -h <ip-addr> -U <username> -d <dbname> Once you're happy the ip-address is working, try just the server-name by itself. You'll want the internet name for the machine which in theory can be different from the Windows network name, but usually is the same. -- Richard Huxton Archonet Ltd
On Fri, 2011-09-16 at 08:14 +0100, Richard Huxton wrote: > On 15/09/11 22:40, Guillaume Lelarge wrote: > > On Thu, 2011-09-15 at 15:30 -0400, Jeff Adams wrote: > >> > >> When I try to connect to the remote machine, I enter \\<server>\<ip_address> > >> into the host name field. > > > >The host field should contain the > > socket complete path, or the host name, or the ip address. > > As Guillaume says - try just the IP address to start with. What you've > been trying is sort-of a Windows networking path. Odd that pgAdmin > doesn't give an error though. > Probably because the OP entered the Windows networking path in the Name field, and didn't change the Host field. In which case, pgAdmin most likely try to connect locally. > If you were using psql you'd type something like: > psql -h <ip-addr> -U <username> -d <dbname> > > Once you're happy the ip-address is working, try just the server-name by > itself. You'll want the internet name for the machine which in theory > can be different from the Windows network name, but usually is the same. > -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com
On 16/09/11 09:01, Guillaume Lelarge wrote: > On Fri, 2011-09-16 at 08:14 +0100, Richard Huxton wrote: >> Odd that pgAdmin >> doesn't give an error though. >> > > Probably because the OP entered the Windows networking path in the Name > field, and didn't change the Host field. In which case, pgAdmin most > likely try to connect locally. Ah - I can see how that would make sense. -- Richard Huxton Archonet Ltd
Thanks Guillaume and Richard. I removed the server from the host name field and entered only the IP address. I then editedmy pg_hba.conf, adding the IP address and it worked! I appreciate all of your help. Jeff > > Thanks for the response Richard. I have tried to connect via pgAdminIII. > When I try to connect to the remote machine, I enter \\<server>\<ip_address> > into the host name field. What I found was it didn't matter what I entered > into the hostname field (I put in random strings to test), it always brought > up the databases on the localhost.... > In pgAdmin, you have a Name field (which is a description, so free text), and you have a Host field. The host field should contain the socket complete path, or the host name, or the ip address. With this, you're able to connect to any PostgreSQL server, as long as their pg_hba.conf file allows it. -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com