Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
chmod og+X /home /home/user seems enough in my case. – PomCompot Nov 19 '15 at 11:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.