postgresql unix socket connections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I'm trying to understand some issues that I'm having with the unix_socket settings and pgsql.
I have 2 machines with pg v9.2.5 with the same next settings :
#listen_addresses = 'localhost'
#unix_socket_directory = ''

in both of the machines I run netstat to check on what socket the postgres listens for connections and I got the same output : 
machine 1
netstat -nlp | grep postgres
tcp        0      0 127.0.0.1:5432              0.0.0.0:*                   LISTEN      2049/postgres
unix  2      [ ACC ]     STREAM     LISTENING     12086  2049/postgres       /tmp/.s.PGSQL.5432

machine 2
tcp        0      0 127.0.0.1:5432              0.0.0.0:*                   LISTEN      3729/postgres
unix  2      [ ACC ]     STREAM     LISTENING     51587140 3729/postgres       /tmp/.s.PGSQL.5432


In both of the machines I tried to check if there are some PG environment variables but nothing was set : 
env | grep PG

The pg_hba in both cases is the default pg_hba.

Now, In machine 1 when I run psql I get the prompt password but in machine 2 I keep getting the next error : 

psql: 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"?

One important thing that I didnt mention, is that I installed in machine 2 package postgresql-libs.x86_64 0:8.4.20-8.el6_9 from the postgres repository (in order to upgrade it to 9.6).

I solved it in machine 2 by setting the unix_socket_directory to /var/run/postgresql/.s.PGSQL.5432 and restarting the database.

My questions are :
1)Why in machine 1, where I dont have a soft link /var/run/postgresql/.s.PGSQL.5432 that directs to the temp dir I can connect succesfully ? (env|grep PG didnt show anything). 
2)What might explain the issue on machine 2? Or maybe machine2 works normally but machine1 has an issue ?


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux