Getting pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')

603 views
Skip to first unread message

Mike Bowerman

unread,
Jun 24, 2021, 3:02:53 AM6/24/21
to Google Cloud SQL discuss
I am running a Python script in a GCP Compute Engine VM to connect to the MySQL instance, and I am getting this error. I am using pymysql for connection. I tracked the error to this file 
`/usr/local/lib/python3.5/dist-packages/pymysql/connections.py` line 703, in _read_bytes and to the following lines of code

```
if len(data) < num_bytes:
        self._force_close()
        raise err.OperationalError(
        CR.CR_SERVER_LOST, "Lost connection to MySQL server during query")
```

Has anyone experienced this issue before?

Sergi Ferre Albiol

unread,
Jun 25, 2021, 8:55:08 AM6/25/21
to Google Cloud SQL discuss

Hello,

You can check this documentation [1] that explains the three different causes of this error and the possible solutions for each case.

[1] https://dev.mysql.com/doc/refman/5.7/en/error-lost-connection.html
Reply all
Reply to author
Forward
0 new messages