简体   繁体   中英

PostgreSQL: could not connect to server: domain socket "/var/run/postgresql/.s.PGSQL.5432"

Linux Mint. PostgreSQL 11.

I'am trying: psql -U postgres

And receive:

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"

In postgresql.conf:

   listen_addresses = '*'
   unix_socket_directories = '/var/run/postgresql'
   unix_socket_permissions = 0777

After ps axf | grep postgres:

6575 ?        Sl     0:01          |       |   \_ xed /etc/postgresql/11/main/postgresql.conf

4906 pts/0    S      0:00          \_ sudo su postgres
4907 pts/0    S      0:00              \_ su postgres
6586 pts/0    S+     0:00                                      \_ grep --color=auto postgres

But

  root@andrej-HP-290-G1-SFF-Business-PC:/etc/postgresql/11/main# netstat -nltp | grep 5432
  root@andrej-HP-290-G1-SFF-Business-PC:/etc/postgresql/11/main# 

How I tried to treat this problem:

  1. ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432

  2. sudo find /tmp/ -name .s.PGSQL.5432

    Result: /tmp/.s.PGSQL.5432. And try under su: psql -U postgres

Running 'pg_lsclusters', I see:

11  main    5432 down   postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log

So, status is down. But when I try 'pg_ctlcluster 11 main start' I receive:

Job for postgresql@11-main.service failed because the service did not 
take the steps required by its unit configuration.
See "systemctl status postgresql@11-main.service" and "journalctl -xe" 
for details.

Executing "journalctl -xe":

 failed to create Unix-сокет in "/tmp
 system bd is switched-off
 failde to start server
  Can't open PID file /run/postgresql/11-main.pid (yet?) after start: 
  No such file or dir
  Failed with result 'protocol'.
  Failed to start PostgreSQL Cluster 11-main.

The problem is solved. I reinstall postgresql and during installing process run 'pg_ctlcluster 11 main start'

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM