Trying to build a Rails project but when I go to create a db I get this error:
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"?
I uninstalled the pg gem
and reinstalled it but I am still getting the error.
Any thoughts on how to resolve this issue?
Resolution:
First Way
I can't up vote yet but the solution that worked for me was to run:
pg_ctl -D /usr/local/var/postgres stop -s -m fast
and then to:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
I am now able to create a db in my rails app.
Thanks @Panayoitis Georgiou (&everyone)!
Second way
If you want to manually start and stop postgresql (installed via homebrew), the easiest way is:
brew services start postgresql
and
brew services stop postgresql