Обсуждение: Remote connection via psql

Поиск
Список
Период
Сортировка

Remote connection via psql

От
Francois Suter
Дата:
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"


Re: Remote connection via psql

От
dima
Дата:
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



Re: Remote connection via psql

От
Tom Lane
Дата:
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

Re: Remote connection via psql

От
Francois Suter
Дата:
> 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"


Re: Remote connection via psql

От
Tom Lane
Дата:
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

Re: Remote connection via psql

От
"scott.marlowe"
Дата:
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.