简体   繁体   中英

Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

The error in the subject is encountered when executing the below command.

heroku run python manage.py db upgrade
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) 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"?

The app works perfectly on local server, but does not migrate to heroku with postgres db.

Have tried countless solutions, nothing has worked yet.

When starting the db, below is the message that comes up

aiting for server to start....2020-10-11 20:14:58.637 +04 [11244] LOG:  starting PostgreSQL 13.0 on x86_64-apple-darwin19.4.0, compiled by Apple clang version 11.0.0 (clang-1100.0.33.8), 64-bit
2020-10-11 20:14:58.641 +04 [11244] LOG:  listening on IPv6 address "::1", port 5432
2020-10-11 20:14:58.641 +04 [11244] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2020-10-11 20:14:58.644 +04 [11244] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-10-11 20:14:58.672 +04 [11246] LOG:  database system was interrupted; last known up at 2020-10-11 20:11:13 +04
2020-10-11 20:14:59.020 +04 [11246] LOG:  database system was not properly shut down; automatic recovery in progress
2020-10-11 20:14:59.034 +04 [11246] LOG:  redo starts at 0/1671320
2020-10-11 20:14:59.034 +04 [11246] LOG:  invalid record length at 0/1671358: wanted 24, got 0
2020-10-11 20:14:59.034 +04 [11246] LOG:  redo done at 0/1671320
2020-10-11 20:14:59.067 +04 [11244] LOG:  database system is ready to accept connections
 done
server started

you just need to restart the server's psql. Be carefull with this database:

sudo service postgresql restart

I had the same error all of a sudden. It resolves. It is not related to psycopg2.connect(dsn)

The issue is; from error '"/var/run/postgresql/.s.PGSQL.5432"?", versus from log "listening on Unix socket "/tmp/.s.PGSQL.5432". First I would try changing your DSN to use host= so you are not trying to connect to a socket. Then you need to sort out why psycopg2 is looking for different socket. Generally that happens when it is compiled/used against libpq on one distribution that puts the socket at /var/run/ and then run on another where the socket is at /tmp/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”? in Odoo Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432” Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432” error with postgresql datababse : Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”? No such file or directory Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432” Error in Django,docker,PostGIS: Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”? Adminer: Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? No such file or directory Is the server running locally and accepting connections on Unix domain socket “/tmp/.s.PGSQL.5432”? BlueHost - No such file or directory Is the server running locally and accepting connections on Unix domain socket “/tmp/.s.PGSQL.5432” No such file or directory Is the server running locally and accepting connections on Unix domain socket “/tmp/.s.PGSQL.5432”? at docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM