'Permission denied in postgres
I missed a bit with chmod and permissions. And now got a lot of problems with access to folders.
If I start server I see in browser:
could not connect to server: Connection refused Is the server running
on host "localhost" (::1) and accepting TCP/IP connections on port
5432?
could not connect to server: Connection refused Is the server
running on host "localhost" (127.0.0.1) and accepting TCP/IP
connections on port 5432?
command
service --status-all
tells that postgres works
[ + ] postgresq works
Next I changed next files
sudo nano /etc/postgresql/9.5/main/postgresql.conf
#listen_addresses = 'localhost'
to
listen_addresses = 'localhost, server_ip, *'
sudo nano /etc/postgresql/9.5/main/pg_hba.conf
add
host all all server_ip/24 trust
then command
psql -U postgres -h server_ip
and error
psql: could not connect to server: Connection refused
Is the server running on host "95.213.200.26" and accepting
TCP/IP connections on port 5432?
The following chain of actions leads to a slightly different error
command
which psql
answer
/usr/bin/psql
sudo su - postgres
No directory, logging in with HOME=/
psql
psql: could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Wich file permissions do I have to change here?
Solution 1:[1]
This question is really hard. I made a great mistake with permissions 777 for /
folder and whole system broke. So it is really easier delete server and start new project.
Solution 2:[2]
Check that unix_socket_directories
on the server is set to the same directory (/var/run/postgresql
) as the default socket directory that was configured when the client was compiled (this requires a server restart).
Alternatively, you can use the --host
option of psql
or set the PGHOST
environment variable to tell the client to look for the socket file in /tmp
, where the server creates it.
It looks like client and server are from different installations, otherwise the configured default should be the same for both. Or you have a bad PGHOST
environment variable set by accident.
Solution 3:[3]
Check listen addres syntax. Use:
listen_addresses = '*'
For the server to listen on both localhost and the server ip.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | General Grievance |
Solution 2 | Laurenz Albe |
Solution 3 |