David Ham David Ham - 1 year ago 126
Ruby Question

Spring rspec can't connect to the database

I have a new Rails 5 app. I installed the

gems as specified in their directions. I can run
by itself and the tests run fine. However, if I run the Spring binstub
I get this:

Running via Spring preloader in process 227
/usr/local/bundle/gems/activerecord- `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
from /usr/local/bundle/gems/activerecord- `new'
from /usr/local/bundle/gems/activerecord- `connect'
from /usr/local/bundle/gems/activerecord- `initialize'
from /usr/local/bundle/gems/activerecord- `new'
from /usr/local/bundle/gems/activerecord- `postgresql_connection'

I have a Rails 4 app that uses the binstubs and
works great. What gives?

rake spec
fails the same way, with that database connection error.

Answer Source

Embarrassing. I had not set up my database.yml properly to inherit settings from *default, so the message above literally was telling me there was no database running. Once I got that fixed, the binstub worked again.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download