Note that there are some explanatory texts on larger screens.

plurals
  1. PORails produces "PGError: server closed the connection unexpectedly" after some timeout
    primarykey
    data
    text
    <p>I have the setup of my Rails app as following:</p> <ul> <li>Rails: 3.0.5 (under Apache proxy) running on RHEL 5.6</li> <li>Postgres: 8.4, running on Windows Server 2008 The 2 servers are on the same LAN.</li> </ul> <p>The problem is, after some idle time, when I make a new request to the Rails app, it gives me the following error:</p> <pre><code>ActiveRecord::StatementInvalid (PGError: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. </code></pre> <p>From what I have researched, it seems that the database connections are dropped after some timeout by Postgres. During this time, from the Rails side,</p> <ul> <li>if I make a request to Rails (1st request), it will display the connection error as above</li> <li>if I make another request to Rails (2nd request), Rails seems to reconnect to Postgres and functions correctly.</li> </ul> <p>It means that I will always experience the first connection error then will have all normal operation again, which is very serious in my case since I'd like to deliver a non-error response to my client.</p> <p>I have looked in following questions and answers, but they do not seem to be appropriate for my case:</p> <ul> <li><a href="https://stackoverflow.com/questions/4675380/pgerror-no-connection-to-the-server-after-idle">&quot;PGError: no connection to the server&quot; after idle</a> (Ubuntu for DB server)</li> <li><a href="https://stackoverflow.com/questions/2166872/how-to-use-tcp-keepalives-settings-in-postgresql">How to use tcp_keepalives settings in Postgresql?</a> (keepalives in MacOS)</li> </ul> <p>Do you have any advice in order to make my app free from db connection errors? Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload