danmcb has asked for the wisdom of the Perl Monks concerning the following question:

Here's an odd problem installing DBD:Pg. Usual steps (have done this module a few times now) ...

The problem I got is "no such file" - it seems that somehow the driver is looking for the wrong named socket ... :


admin@li8-246:~/.cpanplus/5.8.8/build/DBD-Pg-1.49$ perl -Ilib t/01connect.t
1..8
Bail out! Could not connect: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

#
# Program               Version
# Perl                  5.8.8 (linux)
# DBD::Pg               1.49
# PostgreSQL (compiled) ?
# PostgreSQL (target)   ?
# PostgreSQL (reported) ?
# Default port          ?
# DBI                   1.59
# DBI_DSN               dbi:Pg:dbname=pgtest
# No tests run!
admin@li8-246:~/.cpanplus/5.8.8/build/DBD-Pg-1.49$
admin@li8-246:~/.cpanplus/5.8.8/build/DBD-Pg-1.49$
admin@li8-246:~/.cpanplus/5.8.8/build/DBD-Pg-1.49$ ls -al /var/run/postgresql/
total 4
drwxrwsr-x 2 postgres postgres 1024 Nov 30 12:26 .
drwxr-xr-x 7 root     root     1024 Nov 30 08:49 ..
srwxrwxrwx 1 postgres postgres    0 Nov 30 12:26 .s.PGSQL.5433
-rw------- 1 postgres postgres   34 Nov 30 12:26 .s.PGSQL.5433.lock
-rw------- 1 postgres postgres    5 Nov 30 12:26 8.1-main.pid
admin@li8-246:~/.cpanplus/5.8.8/build/DBD-Pg-1.49$

As you can see, the driver is looking for a socket with a different name to the one that actualy exists. What could cause this? I have tried make clean and a rebuild, also restarting postgresql itself. I can connect to the db just fine from the command line too.

Replies are listed 'Best First'.
Re: odd DBD::Pg install problem
by erix (Prior) on Sep 15, 2007 at 00:31 UTC

    The default port for postgresql is 5432 (and the install is assuming it should look there). However your postgres server is apparently on port 5433.

    So you need a way to give the right port number to the install (or alternatively, you could change back to the default port 5432).

    see: the DBD::Pg README under 'TESTING'. (I think you need to set the environment variable 'DBI_DSN'.)