Rspec : PG::ConnectionBad: PQsocket() can't get socket descriptor

ishwr picture ishwr · May 13, 2014 · Viewed 8.3k times · Source

I run my rspec and most of the test were failed. I got the same error for them, which is:

    Failure/Error: Unable to find matching line from backtrace
    ActiveRecord::StatementInvalid:
    PG::ConnectionBad: PQsocket() can't get socket descriptor: BEGIN

I found a question that is similar to my problem, but there is no answer yet and I also tried the solution from this link, but it didn't make any differences for me. I opened my test console and run some simplest queries and it worked.

Answer

Brandon McKay picture Brandon McKay · Mar 26, 2015

There may be a problem with pg: '0.18.1'. I tried reverting to 0.18.0, and I believe the problem has gone away.

I'll open up an issue on the repo after testing a bit more locally. I added this issue on the pg repo.

EDIT: I was wrong. What did in fact help though, was installing the spring-commands-rspec gem. I think what it ended up doing for me was caching it in a state where it worked. Although it could also just as easily cache it in a state where it didn't.