Remote connection via psql

Started by Francois Suterover 23 years ago6 messagesgeneral
Jump to latest
#1Francois Suter
dba@paragraf.ch

I used psql a lot and generally work directly on my development server. Now
sometimes I am on another machine, but when I try to acces the database with
something like this:

psql -d dbname -U username -h 192.168.1.2

I get the following message: "psql: unknown host name: 192.168.1.2"

I am a bit puzzled, because I have no such problem e.g. from a Perl script:

$conn = Pg::connectdb("dbname=dname user=username hostaddr=192.168.1.2
port=5432") or die "Can't open: $!\n";

psql seems to expect a host name rather than an IP address and I haven't
found any other option in the psql doc. Any way out of this?

--------
François

Home page: http://www.monpetitcoin.com/
"A fox is a wolf who sends flowers"

#2dima
_pppp@mail.ru
In reply to: Francois Suter (#1)
Re: Remote connection via psql

Francois Suter wrote:

I used psql a lot and generally work directly on my development server. Now
sometimes I am on another machine, but when I try to acces the database with
something like this:

psql -d dbname -U username -h 192.168.1.2

I get the following message: "psql: unknown host name: 192.168.1.2"

try another syntax:
$ psql -U username -h 192.168.1.2 dbname
it works ok here

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Francois Suter (#1)
Re: Remote connection via psql

Francois Suter <dba@paragraf.ch> writes:

psql -d dbname -U username -h 192.168.1.2
I get the following message: "psql: unknown host name: 192.168.1.2"

Works fine here. What PG version is this, what platform, etc?

regards, tom lane

#4Francois Suter
dba@paragraf.ch
In reply to: Tom Lane (#3)
Re: Remote connection via psql

Francois Suter <dba@paragraf.ch> writes:

psql -d dbname -U username -h 192.168.1.2
I get the following message: "psql: unknown host name: 192.168.1.2"

Works fine here. What PG version is this, what platform, etc?

PG version is 7.2.1, platform is Mac OS X 10.1.5, network uses a router that
serves as a DHCP server, but the dev server mentioned here as a fixed IP
(i.e. 192.168.1.2).

Other types of remote access (e.g. ping, FTP) work fine.

--------
François

Home page: http://www.monpetitcoin.com/
"A fox is a wolf who sends flowers"

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Francois Suter (#4)
Re: Remote connection via psql

Francois Suter <dba@paragraf.ch> writes:

Francois Suter <dba@paragraf.ch> writes:

psql -d dbname -U username -h 192.168.1.2
I get the following message: "psql: unknown host name: 192.168.1.2"

Works fine here. What PG version is this, what platform, etc?

PG version is 7.2.1, platform is Mac OS X 10.1.5, network uses a router that
serves as a DHCP server, but the dev server mentioned here as a fixed IP
(i.e. 192.168.1.2).

OS X eh? I seem to recall a prior thread about that, in which it
emerged that the gethostbyname() routine is kinda broken on OSX.
Everywhere else it will accept a numeric IP, but not on OSX --- unless
you send the query to a nameserver. Or something like that; I think
the guy did find a workaround. Check the list archives.

regards, tom lane

#6scott.marlowe
scott.marlowe@ihs.com
In reply to: Francois Suter (#4)
Re: Remote connection via psql

On Wed, 4 Sep 2002, Francois Suter wrote:

Francois Suter <dba@paragraf.ch> writes:

psql -d dbname -U username -h 192.168.1.2
I get the following message: "psql: unknown host name: 192.168.1.2"

Works fine here. What PG version is this, what platform, etc?

PG version is 7.2.1, platform is Mac OS X 10.1.5, network uses a router that
serves as a DHCP server, but the dev server mentioned here as a fixed IP
(i.e. 192.168.1.2).

Try putting an entry in your /etc/hosts (does OS X have one of those? It
is BSD, but who knows what might be different) for the server and give it
a name and see if you can get a connect then.