简体   繁体   中英

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.

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 ...

如果您能够通过psql从另一台计算机连接(即,您已修改pg_hba.conf以允许此操作),请尝试将本地主机更改为IP。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM