title: Diagnosing 2013 Lost connection to MySQL
body: <p>I am using SQLAlchemy with two MySQL databases. One of these being my development database hosted locally on my machine and the other is a MySQL server provided by ClearDB on Heroku for production.</p>
  
  <p>I have a long running session open with the database while it performs a syncing operation with another service. On my local machine this finishes fine but on production I get the error (2013, 'Lost connection to MySQL server during query').</p>
  
  <p>I've read other posts that say it can either be the size of the request is too big or the pool refresh variable that needs to be adjusted. I don't believe the transaction payload is relatively that large and setting a <code>pool_recycle</code> variable when calling the SQLAlachemy <code>create_engine</code> hasn't seemed to work.</p>
  
  <p>Has anyone else experienced this problem or able to help me narrow down what the underlying reason is for that error - it seems like a catch all and I'm not sure where to go from here.</p>
  
  <p>As requested in comments, both systems return the same values for <code>select @@interactive_timeout, @@wait_timeout</code>: 28800, 28800.</p>
  
  <p>Thanks</p>