Interesting, so your actual error was
PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly