When Postgresql doesnt start on OSX
New-MacBook-Pro:mini-epic cex$ ./bin/server
=> Booting Puma
=> Rails 4.2.1 application starting in development on http://0.0.0.0:8001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/cex/.rvm/gems/ruby-2.2.2@epic-invite/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I tried restarting with brew
New-MacBook-Pro:mini-epic cex$ brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
Same deal. Thanks to https://stackoverflow.com/questions/13410686/postgres-could-not-connect-to-server Remove the PID and you’re sorted.
-rw------- 1 cex admin 88 2 Mar 15:02 /usr/local/var/postgres/postmaster.pid
New-MacBook-Pro:mini-epic cex$ rm /usr/local/var/postgres/postmaster.pid
New-MacBook-Pro:mini-epic cex$ brew services start postgresql
Service `postgresql` already started, use `brew services restart postgresql` to restart.
New-MacBook-Pro:mini-epic cex$ brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)