# "MySQL server has gone away"

**URL:** <https://www.ruby-forum.com/t/mysql-server-has-gone-away/190906>\
**Category:** Rails\
**Created:** [June 30, 2010, 2:42pm UTC](https://www.ruby-forum.com/t/mysql-server-has-gone-away/190906 "2010-06-30T14:42:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fischer1121](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@fischer1121](https://www.ruby-forum.com/u/fischer1121)\
**Post date:** [June 30, 2010, 2:42pm UTC](https://www.ruby-forum.com/t/mysql-server-has-gone-away/190906/1 "2010-06-30T14:42:44Z")

</div>

Hi all,

I am getting the following error in the middle of a long-running  
process: “Mysql::Error: Lost connection to MySQL server during  
query:…”  
When rescued and retried, it throws the next error: “Mysql::Error:  
MySQL server has gone away”

(1) The query is not long and (2) the process does not last longer  
than 8 hours (it’s \< 15 minutes) or idle for a long period.

I’ve tried: ActiveRecord::Base.allow\_concurrency = true,  
ActiveRecord::Base.verification\_timeout = 10, and  
ActiveRecord::Base.verify\_active\_connections!

I can use (1) ActiveRecord::Base.connection\_pool.with\_connection or  
(2) ActiveRecord::Base.verify\_active\_connections! to fix it, but…

when future queries search for data that was inserted previously in  
the process, it is no longer there. It seems like there’s something  
wrapped around everything - tied to the connection - that prevents any  
writes from really persisting to the database until, I’m assuming, the  
process is complete.

How do I fix the lost MySQL connections or at least make writes  
persist to the database mid-process so that when I open a new  
connection the records will be there?

Any help is appreciated.

Thanks,

Blake

---

<div class="post-metadata">

**Author:** ![fischer1121](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@fischer1121](https://www.ruby-forum.com/u/fischer1121)\
**Post date:** [July 3, 2010, 12:13pm UTC](https://www.ruby-forum.com/t/mysql-server-has-gone-away/190906/2 "2010-07-03T12:13:03Z")

</div>

Did you check mysql config on server?
