How to solve django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')?

1,353 views
Skip to first unread message

prateek gupta

unread,
Nov 14, 2018, 5:12:06 AM11/14/18
to Django users
Hi All,

I am using Django 2.0.6, Python 3.6. For connecting with Mysql 5.7 I am using mysqlclient 1.3.12.
Using above environment I have created an admin panel for CRUD operations.
When I select a tabel for viewing it's content following error shows-

django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')

The above error comes only for one table, rest all are working fine.

I tried to set the max_allowed_packet=67108864 in mysql configuration file and in settings.py I have set the CONN_MAX_AGE=6000 but it is not working.

Have anyone faced the same issue?
Let me know if anyone knows how to solve this.

Thanks,
Prateek

Jason

unread,
Nov 14, 2018, 8:36:12 AM11/14/18
to Django users
just checking, but did you restart the mysql server after setting that max_allowed_packet setting?  It won't stick without a restart.


Jason

unread,
Nov 14, 2018, 8:37:46 AM11/14/18
to Django users
also, you might want to update your mysqlclient package.  1.3.12 was released over a year ago, and 1.3.13 was pushed out late June of this year.

prateek gupta

unread,
Nov 14, 2018, 11:27:52 PM11/14/18
to Django users
Thanks Jason!
I have restarted teh server and updated the mysqlclient to 1.3.13 and the issue got resolved now.

prateek gupta

unread,
Nov 15, 2018, 1:39:03 AM11/15/18
to Django users
It is strange again, now I am getting the same error.
Till morning it was working fine but now it is again showing same error.


On Wednesday, November 14, 2018 at 7:07:46 PM UTC+5:30, Jason wrote:

Krishnasagar Subhedarpage

unread,
Nov 15, 2018, 1:57:27 AM11/15/18
to django...@googlegroups.com
Hi Prateek,

Did you check disk info of server instance? What's disk consumption?

Regards,
Krishnasagar Subhedarpage




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9bd1c72a-7c97-49b5-8a37-646e49dbc785%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

prateek gupta

unread,
Nov 15, 2018, 4:11:47 AM11/15/18
to Django users
Hi,

My all db have 20 gb of size.

vineeth sagar

unread,
Nov 15, 2018, 4:21:29 AM11/15/18
to django...@googlegroups.com
Try reducing the connection max age to a lesser value like 3600 maybe?

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Krishnasagar Subhedarpage

unread,
Nov 15, 2018, 4:47:12 AM11/15/18
to django...@googlegroups.com
Okay. Please check error logs of mysql. Its default path: /var/log/mysql/error.log
Please look into any error signals for the same table into it. This could give clue for root cause of issue.
 
Regards,
Krishnasagar Subhedarpage




Reply all
Reply to author
Forward
0 new messages