Reputation: 96
I cannot debug a PsyNet experiment locally because I see the following error in the terminal (I'm using PsyNet v5.0.2 with Dallinger 7.7):
Exception: Failed to connect to Postgres at postgresql://dallinger:dallinger@localhost/dallinger. Is Postgres running on port 5432?
I tried restarging postgres but did not fix it.
Unfortunately I am unable to share the full experiment code here due to privacy constraints, but I'm hoping someone has familiarity with the error message nonetheless.
Upvotes: 2
Views: 23
Reputation: 96
I found a solution to the problem above. Sometimes, PostgresSQL crashes and you may get an error like the one above or also like this:
❯❯ There was a problem connecting to the Postgres database!
This problem can be due to several reasons but I found the following procedure to fix this issue robustly:
You can check if PostgreSQL is running normally with postgres -D /usr/local/var/postgres
; if the above didn't work, this will return an error.
If there is an error, your db has been corrupted due to the crash. Try the following:
rm /usr/local/var/postgres/postmaster.pid
If this does not work or you cannot find the file (postmaster.pid). Then try the following steps in the same order:
brew services stop postgresql
brew uninstall postgresql
rm -rf /usr/local/var/postgres
rm -rf .psql_history .psqlrc .psql.local .pgpass .psqlrc.local
brew install postgresql
brew services start postgresql
createuser -P dallinger --createdb
(Password: dallinger)
createdb -O dallinger dallinger
createdb -O dallinger dallinger-import
This should solve the problem.
Upvotes: 1