0

rake aborted! ActiveRecord::NoDatabaseError: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: database "mydatabase_development" not exist

when i run rake db:create

Ajith
  • 83
  • 4

1 Answers1

0

This often happens because of this issue. If you are on MacOS and have Postgres installed via homebrew then you have two things you should try:

brew postgresql-upgrade-database

will try to upgrade your database using homebrew's built-in script. All your data from your previous work will be preserved.

Otherwise a usually more effective but dangerous approach (you will lose your local databases) is:

rm -rf /usr/local/var/postgres && \
initdb /usr/local/var/postgres -E utf8 && \
brew services restart postgresql && \
createdb $(whoami)
Matthew Zagaja
  • 148
  • 1
  • 10