Mac OSX Lion Postgres does not accept connections on /tmp/.s.PGSQL.5432

£可爱£侵袭症+ 提交于 2019-12-03 03:05:47
Iman

You need to remove the postmaster.pid, which should be in the following path: /usr/local/var/postgres/postmaster.pid

For me, i removed postmaster.pid in /usr/local/var/postgres. fixed me right up.

A simpler solution is to locate where the socket actually is vs where it's expected to be. In my case, I ran:

$ locate PGSQL.5432
/private/var/pgsql_socket/.s.PGSQL.5432
/private/var/pgsql_socket/.s.PGSQL.5432.lock

Then just symlink the expected socket location to the actual socket location.

$ ln -s /private/var/pgsql_socket/.s.PGSQL.5432 /tmp/.s.PGSQL.5432

The system client is being used and not your brew version. The symlink approach only lasts until the next restart. This approach fixes the root issue I believe

  1. sudo edit /etc/paths
  2. Move the line containing /usr/local/bin to the top of the file. (Before /usr/bin)
  3. Uninstall your postgres gem(s) (gem uninstall pg)
  4. Start up new shell to load the new environment settings
  5. bundle
Atmaram Shetye

That is not an OS X specific issue. You will need to clean up your postgres installation and then reinstall it again. I have faced this issue on my ubuntu 12.04. While cleaning your previous installation, you will need to remove all packages starting with postgres (postgresql, postgresql-common, postgresql-client etc), in other words, postgres*. I have not used brew, have used port on OS X Lion. I guess the equivalent command should be sudo brew remove postgres*. A sudo brew install postgresql should then do the trick.

Also, if you feel the server is already running, you can try sudo -u postgres createuser. If that fails, you will need to reinstall.

However, the output of your ps aux | grep post is actually the grep command itself. Not of the postgres server running.

EDIT: Looks like the following link could be of help https://dba.stackexchange.com/questions/21587/postgresql-is-running-locally-but-i-cannot-connect-why If yes, then this question might be a duplicate.

I had the same problem on Mac Serria. In Mac Serria you can find postmaster.pid inside /Users/<user_name>/Library/Application Support/Postgres/var-9.6 if you used GUI installer rather than homebrew.

Once you delete this file then everything should work fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!