0

I just installed postgresql 9.4 on a brand new 15.04 ubuntu install and I'm unable to start the psql server. Every time I try to run sudo -u postgres psql, it gives me the following error:

psql: 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"?

I have tried every single solution posted here and on every other forum, but none have worked except one:

http://ubuntuforums.org/showthread.php?t=869080

sudo mkdir -p /usr/local/pgsql/data
sudo chown -R postgres:postgres /usr/local/pgsql/
sudo sudo su postgres
cd /usr/lib/postgresql/9.4/bin/
./initdb -D /usr/local/pgsql/data
./postgres -D /usr/local/pgsql/data

I tried changing the init.d script as stated there but that doesn't work, and the solution above only seems to work once, after that, a file locks up and I'm unable to run ./postgres -D /usr/local/pgsql/data

Can someone please help? I've tried removing, purging, reinstalling, multiple-versions, etc. Every single time I get the same error. hanks! T

Andrea
  • 394
  • 2
  • 15
  • You might want ti run it under `strace`, to check what is failing – Severin Pappadeux Jul 01 '15 at 00:43
  • You say you've tried every proposed solution. Please give details. What exactly have you tried? Also, *how* did you install PostgreSQL, exactly? From where? – Craig Ringer Jul 01 '15 at 01:24
  • See also http://stackoverflow.com/q/31144672/398670 – Craig Ringer Jul 01 '15 at 01:43
  • When the postgresql server package is installed there's probably a non-fatal error saying that no cluster (=instance) could be created. You need to figure out why and solve that problem. It's often a misconfiguration of locales. – Daniel Vérité Jul 01 '15 at 12:09

1 Answers1

0

psql is not the PostgreSQL server. It is the command-line client that connects to an already-running server.

It looks like you had no PostgreSQL server running, so there was nothing to connect to. Note that the error message says Is the server running...

As you have already noted, to start a PostgreSQL server you need to run postgres -D /path/to/datadir (or preferably something like pg_ctl -D /path/to/datadir -w start -l pgstartup.log).

Rather than doing so manually, you should have your operating system do this automatically when you start up. Most PostgreSQL installers and packages will set this up for you. Some require additional steps to enable it, which will be explained in their documentation. You haven't mentioned how you installed PostgreSQL / from where, so I can't be more specific about this.

If you use the Ubuntu PostgreSQL packages or http://apt.postgresql.org/ packages, they'll register a service for you.

Please see https://help.ubuntu.com/community/PostgreSQL

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • Thank you. I installed via apt-get install postgresql would this have caused the installer not to be setup? I didn't run into this issue in the install I had on my other computer – Andrea Jul 02 '15 at 01:22