Reputation: 21
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
Upvotes: 0
Views: 79
Reputation: 21
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)!
Upvotes: 1
Reputation: 1263
Run this command to manually start the server:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
if that is not woking try the following
For pure installing postgresql on Mac OS, the process will be (using brew command):
brew install postgresql
then if you want to automatically run postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
or else you just want to run it anytime you want:
postgres -D /usr/local/var/postgres
If your case is more complicated, let's brew uninstall postgresql and redo these steps.
Hope it helps!
Upvotes: 1