Connection rejected. The server runs locally and accepts

So, I got an error while trying to connect to a Postgres instance on OSX.

I get this error:

 Connection refused
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

I run this:

ps -ax | grep postgres 

And get the following:

 7782 ??         0:00.06 /usr/local/opt/postgresql@9.6/bin/postgres -D /usr/local/var/postgresql@9.6
 7786 ??         0:00.00 postgres: checkpointer process     
 7787 ??         0:00.01 postgres: writer process     
 7788 ??         0:00.00 postgres: wal writer process     
 7789 ??         0:00.00 postgres: autovacuum launcher process     
 7790 ??         0:00.00 postgres: stats collector process     
 7794 ttys000    0:00.00 grep postgres

/tmp/.s.PGSQL.5432 exists, although it does have a "daemon" group, and not everything that has a "wheel".

I am configuring Postgres 9.6 via brew.

What could be the reason for this?

My pg_hba.conf looks like this:

host  all  all  0.0.0.0/0  trust
hostnossl    all          all            0.0.0.0/0  trust

What could be the reason for this?

Here is what postgres magazine says:

2017-12-15 19:40:37 UTC LOG:  database system was shut down at 2017-12-15 19:40:32 UTC
2017-12-15 19:40:37 UTC LOG:  MultiXact member wraparound protections are now enabled
2017-12-15 19:40:37 UTC LOG:  database system is ready to accept connections
2017-12-15 19:40:37 UTC LOG:  autovacuum launcher started

I just don't see BELOW that can cause this.

Full pg_hba.conf:

#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access.  Records take one of these forms:
#
# local      DATABASE  USER  METHOD  [OPTIONS]
# host       DATABASE  USER  ADDRESS  METHOD  [OPTIONS]
# hostssl    DATABASE  USER  ADDRESS  METHOD  [OPTIONS]
# hostnossl  DATABASE  USER  ADDRESS  METHOD  [OPTIONS]
#
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# Default:
# Added by ansible
# Added by ansible
host  all  all  0.0.0.0/0  trust
hostnossl    all          all            0.0.0.0/0  trust
local  all  all    trust
# Password hosts

# Trusted hosts

# User custom
+4
source share
1 answer

The problem has nothing to do with pg_hba.conf, because your connection attempt is rejected by the operating system - the PostgreSQL server is not yet involved.

Some things to check:

  • , UNIX , ?

  • :

    ls -l /tmp/.s.PGSQL.5432
    

    , OSX UNIX, , .

    , PostgreSQL unix_socket_permissions .

    (, /tmp, , .)

  • ?

    ,

    lsof -p 7782 | grep PGSQL
    

    7782 - postmaster.

    PostgreSQL unix_socket_directories , .

+3

Source: https://habr.com/ru/post/1690875/


All Articles