title: "MySQL server has gone away" with Ruby on Rails
body: <p>After our Ruby on Rails application has run for a while, it starts throwing 500s with "MySQL server has gone away". Often this happens overnight. It's started doing this recently, with no obvious change in our server configuration.</p>
  
  <pre><code> Mysql::Error: MySQL server has gone away: SELECT * FROM `widgets`
  </code></pre>
  
  <p>Restarting the mongrels (not the MySQL server) fixes it.</p>
  
  <p>How can we fix this?</p>