I'm really new to PostrgreSQL, and I've run into an issue I don't really know how to solve.
I'm currently using the PostreSQL 10 app for OSX; and I'm trying to recreate a Rails app database using rails db:drop db:create db:migrate
. I get the following error:
PG::ObjectInUse: ERROR: database "app_development" is being accessed by other users
This other session is the Postgres app keeping a connection open: if I run ps -ef | grep postgres
, I get
502 38332 1 0 2:57PM ?? 0:00.15 /Applications/Postgres.app/Contents/Versions/10/bin/postgres -D /Users/user/Library/Application Support/Postgres/var-10 -p 5432
502 38334 38332 0 2:57PM ?? 0:00.01 postgres: checkpointer process
502 38335 38332 0 2:57PM ?? 0:00.07 postgres: writer process
502 38336 38332 0 2:57PM ?? 0:00.02 postgres: wal writer process
502 38337 38332 0 2:57PM ?? 0:00.04 postgres: autovacuum launcher process
502 38338 38332 0 2:57PM ?? 0:00.17 postgres: stats collector process
502 38339 38332 0 2:57PM ?? 0:00.01 postgres: bgworker: logical replication launcher
502 38342 38332 0 2:57PM ?? 0:00.21 postgres: user app_development [local] idle
502 38661 38432 0 3:06PM ttys004 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn postgres
I can't just stop the Postgres app and then run the rails db:drop
command, because then I get the following 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"?
How can I actually recreate my database? Thanks in advance
Try to restart it
brew services restart postgresql