Dreaded "psql: could not connect to the server: no such file" error with Homebrew / OSX

I just restarted OSX (Sierra 10.12.6), and when I try to run psql (which used to work fine), I get scary:

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

Trying brew services restart postgresql does not help, and brew services start postgresql claims that the service is already running.

Still ps auxw | grep postgres ps auxw | grep postgres indicates that Postgres processes are not running. Is Homebrew Confused?

which psql shows /usr/local/bin/psql .

Here is what I tried ...

psql -h localhost doesn't matter.

I ran brew uninstall --force postgresql and then brew install postgresql , which doesn't matter. I also tried to do the same after brew doctor and brew update , which again doesn't matter.

I saw advice on deleting the postmaster.pid file, but there is no such file in /usr/local/var/postgres/ . Nor does the server.log file server.log in this directory.

Running locate PGSQL.5432 does not display files.

I own the directory /usr/local/var/postgres with permissions drwxr-xr-x .

Perhaps I could have installed KyngChaos postgres at some point in the past.

I checked the .plist file specified in the output of the brew services list ( ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist ), it shows the following:

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>homebrew.mxcl.postgresql</string> <key>ProgramArguments</key> <array> <string>/usr/local/opt/postgresql/bin/postgres</string> <string>-D</string> <string>/usr/local/var/postgres</string> </array> <key>RunAtLoad</key> <true/> <key>WorkingDirectory</key> <string>/usr/local</string> <key>StandardErrorPath</key> <string>/usr/local/var/log/postgres.log</string> </dict> </plist> 

I really want not to delete all my postgres databases, if possible, because I am currently in a remote place where I do not need to reserve them!

+5
source share

Source: https://habr.com/ru/post/1271786/


All Articles