Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres, a fresh install of Mavericks and rails. Cannot fix this database connection issue...

There are a few other issues similar to this on stack overflow however they don't fix it and are not related to Mavericks, I think this is a Mavericks specific issue.

I have a fresh install of Mavericks and I have brew installed postgres however I’m getting a strange error when running my rails app:

could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

Postgres is up and running, I can view the whole database in the command line. Rails console also throws this error.

There is a /tmp/.s.PGSQL.5432.lock file that looks similar t othe one this is looking for.

There is no .s.PGSQL.5432 file in the directory it’s looking for.

In my database.yml in rails I have the host set as localhost.

Can anyone tell me what this error is about and how to fix it please.

like image 647
MintDeparture Avatar asked Dec 06 '25 08:12

MintDeparture


1 Answers

Your client (psql or whatever) is configured to look for unix sockets in /var/run but your server is using /tmp. This suggests that your psql is an old version rather than whatever you compiled - check your PATH.

You can use the path as a hostname:

psql -h /tmp -p 5432 ...
like image 175
Richard Huxton Avatar answered Dec 08 '25 23:12

Richard Huxton