Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 http://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.

share|improve this question
    
Is either Django or postgresql in a chroot environment? Try using TCP/IP: specify host as localhost in your Django database config. –  Craig Ringer Apr 21 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 at 15:47
    
Using localhost worked, I can't tell what is wrong, but now it runs fine. Thankyou –  Thyssen Apr 21 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? –  Jorge Castro Apr 21 at 18:46
add comment

2 Answers 2

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.

share|improve this answer
    
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 at 18:42
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.