3

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:

  1. PostgreSQL is running and the socket-file .s.PGSQL.5432 is created just as stated in the config.
  2. Django is asking for the exact same file, but it cannot see it.
  3. 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.

8
  • 1
    Is either Django or postgresql in a chroot environment? Try using TCP/IP: specify host as localhost in your Django database config. Apr 21, 2014 at 2:44
  • No chroot environments, Django is running in a virtualenv and is started with a newrelic wrapper. But i'll try using TCP/IP.
    – Thyssen
    Apr 21, 2014 at 15:47
  • 1
    Using localhost worked, I can't tell what is wrong, but now it runs fine. Thankyou
    – Thyssen
    Apr 21, 2014 at 18:41
  • @CraigRinger or Thyssen can one of you guys write it up as an answer so we can mark the question as solved? Apr 21, 2014 at 18:46
  • If I purge my previous version of Postgresql, I won't lose my database, will I?
    – bbneo
    Jul 30, 2014 at 14:34

2 Answers 2

1

I'm sure there is a better answer than this. But I had the same error in my dev environment, ran

sudo apt-get purge postgresql-9.1

and rebuilt everything in 9.3 with no issues. But I only had a couple users and small databases with migrations scripts, so you may not want to go this route.

1
  • Purging didn't really make a difference, I suspect the problem is hidden somewhere in the 9.3 branch config files, but changing to localhost connection worked.
    – Thyssen
    Apr 21, 2014 at 18:42
0

Didn't find the issue, but running through TCP/IP localhost made the server run, and it is good enough for this small server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .