I'm running an Ubuntu VPS where i'm am upgrading to 14.04. everything has gone smoothly so far. Except the PostgreSQL migration from 9.1 to 9.3.
The server hosts a Django 1.6 site and the traceback that I get is this:
File "/srv/virtualenvs/formgiv/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
OperationalError: 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"?
Before testing this I ran these commands basically:
service postgresql stop (stops both running server versions)
su postgres
/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
exit
service postgresql start
As far as I can tell:
- PostgreSQL is running and the socket-file .s.PGSQL.5432 is created just as stated in the config.
- Django is asking for the exact same file, but it cannot see it.
- This is a standard config and was working without a hitch on Ubuntu 13.10 with PostgreSQL 9.1
The error resembles these two old posts: Cannot connect to postgresql on port 5432 and https://stackoverflow.com/questions/10829464/postgresql-and-django-unix-domain-socket except I can't seem to get anything from following the suggestions that I already have found out.
I really hope someone can spot the obvious mistake this hopefully is.
host
aslocalhost
in your Django database config.