Postgres could not connect to Server
Before you came to this problem, I assume you backup your Postgres database already.
Recently I upgraded my Mac OS X 10.9 (Mavericks) to Mac OS X 10.10 (Yosemite). All is installations process on new OS is working perfectly fine, and a lot for features on 10.10 is new to the dependencies of my previews web apps. WhenI tried to run one of my web-apps that was working previously on 10.9, it cannot connect the Posgtres DB to the Web App server. The errors goes like this
$ psql 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"?
Then I tried to google around and found some answers which I tried to apply on my terminal.
One thing I tried was to make directory and check.
brew uninstall postgres brew install postgres sudo mkdir /var/pgsql_socket/ sudo ln -s /private/tmp/.s.PGSQL.5432 /var/psql_socket/ rm /usr/local/var/postgres/postmaster.pid pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
postgres -D /usr/local/var/postgres — it will give you a much more verbose output if postgres fails to start.
In my case, running
rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8removed my old databases and then reinitialized the postgres db schema.
Check that the socket file exists.
Andre$ ls -l /tmp/.s.PGSQL.5432 srwxrwxrwx 1 tech3 wheel 0 Feb 23 16:26 /tmp/.s.PGSQL.5432
Andre$ grep unix_socket /usr/local/var/postgres/postgresql.conf #unix_socket_directories = '/tmp' # comma-separated list of directories #unix_socket_group = '' # (change requires restart) #unix_socket_permissions = 0777 # begin with 0 to use octal notation
Then another thing was to unload plist file, remove pid and load back plist file.
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist rm /usr/local/var/postgres/postmaster.pid launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Additionally you have to check if you have the latest XCode ver 6.1.1 on your machine and also Command Line Tools for OS X 10.10 (Yosemite). Please refer to the link below – ciao!