Server Fault is a question and answer site for system and network administrators. 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 am getting an error trying to visit my Django app. I am running Gentoo and the web server is Apache with the mod_wsgi module to display Django. The error says

OperationalError at /admin/
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"?

I know Django can connect to the Postgres database since I can run python syncdb successfully. I can also enter the interactive terminal with psql -U root -d mysite.

The ls -la of the socket is

root@ip-99-99-99-99 /var/run/postgresql # ls -la
total 12K
drwxr-x--- 2 postgres 4.0K Mar  7 18:39 ./
drwxr-xr-x 6 root     4.0K Mar  7 22:58 ../
srwxrwxrwx 1 postgres    0 Mar  7 23:31 .s.PGSQL.5432
-rw------- 1 postgres   71 Mar  7 23:31 .s.PGSQL.5432.lock
share|improve this question
up vote 4 down vote accepted

Curious... as a quick test, try running chmod o+rx /var/run/postgresql -- if that fixes the problem (as I suspect it will) then you'll need to diagnose why the permissions are screwed up on the directory. On my system (Debian Squeeze) the perms are 2775 postgres:postgres; while it isn't necessary to have that particular mode, you'll want (at least) o+x to allow other users to traverse the directory to get to the socket.

share|improve this answer
Perfect that solved it! Thank you! – hobbes3 Mar 7 '12 at 23:56

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.