title: Google App Engine and Cloud SQL: Lost connection to MySQL server at 'reading initial communication packet'
body: <p>I have a Django app on Google App Engine app which is connected to a Google Cloud SQL, using the <a href="https://developers.google.com/appengine/docs/python/cloud-sql/django">App Engine authentication</a>.</p>
  
  <p>Most of the time everything works fine, but from time to time the following exception is raised:</p>
  
  <pre><code>OperationalError: (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 38")
  </code></pre>
  
  <p>According to <a href="https://developers.google.com/cloud-sql/docs/mysql-client">the docs</a>, this error is returned when:</p>
  
  <blockquote>
    <p>If Google Cloud SQL rejects the connection, for example, because the IP address your client is connecting from is not authorized.</p>
  </blockquote>
  
  <p>This doesn't make much sense in my case, because the authentication is done by the App Engine server.</p>
  
  <p>What might cause these sporadic errors?</p>