loganathan
loganathan

Reputation: 6136

PG CONNECTION TIME OUT ERROR

I am frequently getting Pg Connection timeout error in my application. I tried to fix it by upgrading the system memory, also updated the pg gem but the issue is still occurring. Anybody's help will be really appreciated.

(ActiveRecord::StatementInvalid) "PGError: server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\n: BEGIN"

Upvotes: 0

Views: 2289

Answers (2)

Jack Kinsella
Jack Kinsella

Reputation: 4631

For what it's worth, the easiest solution is ActiveRecord::Base.connection.reconnect! once connectivity is re-established.

Upvotes: 1

Craig Ringer
Craig Ringer

Reputation: 324285

Both the client and server think that the other vanished unexpectedly. This suggests that you're having networking problems. Look into the network between client and server:

  • NAT routers or connection-tracking stateful firewalls with short-lived or undersized connection tables;
  • Physical connectivity problems with cables, WiFi, etc
  • Faulty switches, hubs and routers
  • Buggy software host-based firewalls
  • ... etc

Upvotes: 1

Related Questions