postgresql unix socket connections

From: Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com>
To: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: postgresql unix socket connections
Date: 2019-01-09 08:35:41
Message-ID: CA+t6e1kUQj+ZGPZZPjW7Fbg=69UaLj-cRgSGZiWFk+bR=-H5+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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 ?

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Mariel Cherkassky 2019-01-09 08:46:58 Re: postgresql unix socket connections
Previous Message Amit Langote 2019-01-09 00:30:08 Re: Query with high planning time at version 11.1 compared versions 10.5 and 11.0