# Mysql::Error: Lost connection to MySQL server during query

**URL:** <https://www.ruby-forum.com/t/mysql-lost-connection-to-mysql-server-during-query/95642>\
**Category:** Rails\
**Created:** [January 19, 2006, 3:22am UTC](https://www.ruby-forum.com/t/mysql-lost-connection-to-mysql-server-during-query/95642 "2006-01-19T03:22:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [January 19, 2006, 3:22am UTC](https://www.ruby-forum.com/t/mysql-lost-connection-to-mysql-server-during-query/95642/1 "2006-01-19T03:22:27Z")

</div>

Earlier I posted a question about password hashes because I thought that  
was  
the last thing in my app that I touched (mysql GRANTs) but after poking  
through my logs I am now not so sure it is the password.

In my log I see:

ActionView::TemplateError (Mysql::Error: Lost connection to MySQL server  
during query: SELECT \* FROM newsitems ORDER BY created DESC LIMIT 4)  
on  
line #84 of app/views/layouts/application.rhtml:

It now seems to me that I do log in ok and that what I thought was a  
password problem was a red herring.

This seems to be a known problem on some platforms  
[Peak Obsession](http://wiki.rubyonrails.com/rails/pages/Mysql+Connection+Problems/) I am  
using webrick on FC4. But the puzzling thing to me is that this has  
been  
running for weeks with no problems. gem install mysql fails but I  
can’t  
use the method provided at [http://www.ocsforums.com/showthread.php?t=132](http://www.ocsforums.com/showthread.php?t=132)  
because it fails with can’t find header files for ruby.

Has anyone else had MySQL “Lost Connection” problems?

Gary

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [January 19, 2006, 3:28am UTC](https://www.ruby-forum.com/t/mysql-lost-connection-to-mysql-server-during-query/95642/2 "2006-01-19T03:28:29Z")

</div>

This patch may fix your problem: [http://dev.rubyonrails.org/ticket/3433](http://dev.rubyonrails.org/ticket/3433)

Does your log file look like two requests are running at the same time?  
If  
so, the above patch should fix that.

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [January 19, 2006, 3:43am UTC](https://www.ruby-forum.com/t/mysql-lost-connection-to-mysql-server-during-query/95642/3 "2006-01-19T03:43:34Z")

</div>

It’s the WEBrick server code in Rails, so it is a Rails patch.

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [January 19, 2006, 3:40am UTC](https://www.ruby-forum.com/t/mysql-lost-connection-to-mysql-server-during-query/95642/4 "2006-01-19T03:40:33Z")

</div>

No it does not appear to be issuing two requests, according to my log.

Thx for the suggestion though. I may still try your patch. It is  
applied  
to WEBrick right? not Rails?

Gary  
----- Original Message -----  
From: “Tom F.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Wednesday, January 18, 2006 8:50 PM  
Subject: RE: [Rails] Mysql::Error: Lost connection to MySQL server  
during  
query

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [January 19, 2006, 3:52am UTC](https://www.ruby-forum.com/t/mysql-lost-connection-to-mysql-server-during-query/95642/5 "2006-01-19T03:52:36Z")

</div>

Thanks to all that replied with suggestions. Thanks to Tom F. for  
suggesting a patch. I ended up basically following the directions here  
[http://www.ocsforums.com/showthread.php?t=132](http://www.ocsforums.com/showthread.php?t=132) and I was able to install  
the  
mysql gem. However I did not need to make the change from  
i386-redhat-linux-gcc to i386-redhat-linux-gcc32. I just compiled it  
locally and installed it again.

I’m still unclear why this broke in the first place, as I said it had  
been  
in operation for weeks. But whatever, I’m back in business!

Gary  
----- Original Message -----  
From: “Gary H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Wednesday, January 18, 2006 9:03 PM  
Subject: Re: [Rails] Mysql::Error: Lost connection to MySQL server  
during  
query
