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.

Thyssen
  • 31
  • 1
  • 4
  • 1
    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 '14 at 02: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 '14 at 15:47
  • 1
    Using localhost worked, I can't tell what is wrong, but now it runs fine. Thankyou – Thyssen Apr 21 '14 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 '14 at 18:46
  • If I purge my previous version of Postgresql, I won't lose my database, will I? – bbneo Jul 30 '14 at 14:34
  • @CraigRinger: Could you please convert your upvoted comment to an answer so that schmucks like me who go around hunting for "solved" questions without an answer don't have to look at this one any more? **;-)** (And I'll upvote if you drop me a note and it's a good one too!) – Fabby Jun 01 '15 at 19:59
  • @Fabby it's a workaround not a real explanation and fix so in this case i'd rather not. – Craig Ringer Jun 01 '15 at 22:49
  • Too bad, because it's better then anything here below... ;-) – Fabby Jun 02 '15 at 07:34

2 Answers2

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.

user272057
  • 11
  • 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 '14 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.

Thyssen
  • 31
  • 1
  • 4