# Lost connection to MySQL server during query

**URL:** <https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/175361>\
**Category:** Rails\
**Created:** [September 11, 2009, 8:08pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/175361 "2009-09-11T20:08:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flamingsole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@flamingsole](https://www.ruby-forum.com/u/flamingsole)\
**Post date:** [September 11, 2009, 8:08pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/175361/1 "2009-09-11T20:08:57Z")

</div>

Thank you for any help you might provide. This is keeping me awake  
nights…

Mysql::Error in #  
Lost connection to MySQL server during query  
RAILS\_ROOT:   
Application Trace  
c:/ruby/lib/ruby/site\_ruby/1.8/mysql.rb:1116:in `write`  
…

This error has come up intermittently but often for many months… It  
is keeping us from rolling out a RoR system. I’ve devoted a day a week  
for the past two months to try to fix it without any success. I’ve  
fiddled with:  
MySQL parameters – no effect from  
High values for all timeouts  
environment.rb – no effect from  
ActiveRecord::Base.connection.instance\_eval  
{@connection.reconnect = true}  
database.yml – no effect from  
timeout: 8000  
reconnect: true

The problem doesn’t happen with batch programs – only with Rails.

It happens with about one transaction in twenty.

The problem doesn’t seem to correlate with database load, or idle time,  
or anything else.

Any ideas or suggestions? Any suggestions on how to collect good data  
on what’s causing this?

Windows 2000 Server SP4  
Apache 2.2  
MySQL 5.1.32  
Ruby 1.8.6  
ActiveRecord 2.3.4  
mysql 2.8.1
