18

I did a silly mistake. I wanted to set postgres permissions to a folder for exporting data from my database. So I set something like sudo chmod 777 -u postgres /home/user and then my home partition only has root permissions and nothing worked without root permissions. I solved this problem by using sudo chown user /home/user and then I set the permissions manually in the file manager on linux. It was very stupid, I didn't knew very much about allocating permissions to directories and users.

The Problem is now, that I can't connect to my database anymore.

 ~ $ sudo -u postgres psql
[sudo] password for user: 
could not change directory to "/home/user"
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"?

I think I want to connect in a folder where the postgres user can't read.

Restarting the server with sudo service postgresql restart doesn't work as well.

I'm using PostgreSQL 9.1.

1 Answer 1

18

I solved the problem with the help of a relative.

The first problem was that my /home and /home/user folder didn't have the right permissions.

We set them correctly with chmod og+rX /home /home/user.

Then I forgot, that I created a new PGDATA directory in /home/user. And this directory had the wrong permissions. So we set them again for the user postgres with chown postgres:postrgres -R /home/user/PGDATA.

I decided to place the PGDATA directory in /home/user because of huge log-files that where produced during raster data queries with my PostGIS/PostgreSQL database. Sometimes I'm using Sublime Text 2 for queries and I quit them without stopping the database process and then the logfile became larger and larger and I was running out of space and nothing worked anymore.

4
  • 3
    chmod og+X /home /home/user seems enough in my case. Commented Nov 19, 2015 at 11:43
  • 1
    chmod og+X /home /home/user should work but it is also a security risk. There's a reason why the $HOME has 700 permission. Commented Apr 5, 2020 at 17:58
  • Thank you for sharing. I was struggling with this problem during gvm setup. Your post solves the problem! Commented Aug 28, 2023 at 16:00
  • this solves my problem too, well defined Commented Feb 18, 2024 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.