Reputation: 121
I am new to Ruby on rails. I've created basic demo apps by tutorial learning by examples.
First it working fine, one week later i got error when type rails s
,
Error
PG::ConnectionBad
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 am using PostgreSQL database.
I am on MAC OS X 10.8.5
I have found similar questions on SO, but they are experiencing at some advance stage and thus involves some advance solutions.
when type
which psql
/usr/local/bin/psql
Upvotes: 0
Views: 448
Reputation: 10328
It seems upgrading your OS has changed the permissions on the directory where Postgres keeps its data.
Run
sudo chown -R sabir:staff /usr/local/var/postgres
to make your user account the owner of that directory. Enter your password when it asks for it; you will not see the characters as you enter them.
The homebrew version of Postgres includes the ability to start automatically. To check whether your installation does, run
ls -l ~/Library/LaunchAgents/
You should see a line ending with homebrew.mxcl.postgresql.plist
. If you do not see this line, run
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
in order to have it start automatically.
Finally, run
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
to make sure Postgres is active now. Confirm by typing
psql -l
Upvotes: 1
Reputation: 1764
When you install postgres using homebrew, than maybe you just started it manually in foreground. So after closing the terminal window postgres was not running anymore.
I'd suggest to do the following steps:
ps aux | grep postgres
sudo kill -9 {POSTGRES_PID}
brew info postgres
to see how to start it manually (or on startup etc.)postgres -D /usr/local/var/postgres
I hope, that will help you out. If you installed postgres on another basis, I can change my answer accordingly.
Upvotes: 0