Error message.
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”?
There are many cases of this problem, the following are some of the cases I have encountered so far, and I will continue to add them afterwards.
1. The .s.PGSQL.5432 and .s.PGSQL.5432.lock files in the /tmp path are deleted.
Solution: Restart the database $sudo service postgresql restart
2. Modify the listening port.
Before I used 5434 to listen, but later I changed it to 5432, the database started, but psql could not enter the database, but I could enter it by psql -p 5432.
Solution: The port PGPORT was configured during installation. modify the port specified in ~/.bash_profile or /etc/profile file.
3. modified unix_socket_directories in postgresql.conf
Quoting from which.
“First, let’s look at the socket file “/tmp/.s.PGSQL.1921″, where 1921 is the port number of pg; the socket file can be configured with the
postgresql.conf file with the following parameters.
#unix_socket_directory = ”
#unix_socket_permissions = 0777
Note: The parameter unix_socket_directory is used to configure the directory of the socket file, the default is the /tmp directory, and the parameter
unix_socket_permissions is used to set the permissions of the socket file.”
Solution:Specify the host and connect with psql -h
Similar Posts:
- [Solved] createdb: could not connect to database postgres: FATAL: Peer authentication failed for user “postgres”
- The use of libpqxx interface in Linux solves the error of PSQL: connections on UNIX domain socket “/TMP/.S.pgsql.5432”
- [Solved] PSQL: fatal: the database system is starting up
- PostgreSQL Connect Error: FATAL: no pg_hba.conf entry for host
- CentOS7 MYSQL Connect Error: [ERROR] InnoDB: The innodb_system data file ‘ibdata1’ must be writable
- [Solved] Laravel Groupby error: laravel which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
- [Solved] zabbix Monitor postgres Error: “sh:psql command not found”
- [Warning] Using a password on the command line interface can be insecure. (Solved)
- [Solved] k8s Deploy postgresql Error: initdb: error: directory “/var/lib/postgresql/data” exists but is not empty
- An error prompt appears during the installation of win10 PostgreSQL: “failed to load SQL modules into the database cluster”