I can connect fine with PHP and locally using Psql, but Perl does not.
my $dbh = DBI->connect("DBI:Pg:dbname=mydb,host=localhost:5432","user","pass",{'RaiseError' => 1});
I believe the error is because my socket is in tmp:
postgres@host/opt/psql/bin $ netstat -an | grep 5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
unix 2 [ ACC ] STREAM LISTENING 24728255 /tmp/.s.PGSQL.5432
unix 3 [ ] STREAM CONNECTED 24729004 /tmp/.s.PGSQL.5432
And when I run my simple perl script it seems to look in /var/run:
./test.pl
DBI connect('dbname=mydb','user',...) failed: 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"? at ./test.pl line 6
I tried to simply create a symlink, but that doesn't seem to be working:
sudo ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432
ln: failed to create symbolic link `/var/run/postgresql/.s.PGSQL.5432': No such file or directory
Some other simple stuff: pg_hba.conf trusts all localhost connections as well as those of my subnet.
postgresql.conf has the following:
listen_addresses = '*'
127.0.0.1instead oflocalhost. That should cause it to use TCP instead of a UNIX socket.