Intermittent Mysql Connection error in ROR app

55 views
Skip to first unread message

Loganathan Sellappa

unread,
Apr 11, 2019, 1:21:03 AM4/11/19
to Ruby on Rails: Talk
Hi Everyone, 

I'm getting the below error randomly in my Ruby On Rails application whenever the number of requests increases to the server.


Mysql2::Error::ConnectionError (Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)):

I'm not sure whether it is because of my server memory or is it something to do with mysql2 gem. Any help would be really appreciated, thanks in advance.

Ruby '2.5.0'
Rails '5.2.0
Mysql2 0.5.2
Phusion Passenger 5.3.4
Server version: Apache/2.4.6 (CentOS)
RAM SIZE: 1.5GB
MySQL Community Server (GPL): 5.6.41
Regards,
Loganathan
Message has been deleted

Unni

unread,
Apr 11, 2019, 10:53:28 AM4/11/19
to rubyonra...@googlegroups.com
Hi

You can try the following:

1. In your database.yml, increase the `pool` size. 
2. In database.yml, pass `reconnect: true`
3. Make sure `max_connections` in your Mysql server configuration is a number big enough to support the pool size you are setting.

Unni

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3f2416a7-1ba8-44c3-81e6-17384309af43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Unni

Fatih Orhan

unread,
Apr 19, 2019, 1:38:56 PM4/19/19
to Ruby on Rails: Talk
Error number 2 means file not found. This is likely a MySQL server problem.
I suggest checking system logs, MySQL logs and auth log.
This guy found the reason to be hackers trying to get in: http://forums.devshed.com/mysql-help-4/intermittent-cant-connect-mysql-socket-937298.html

Loganathan Sellappa

unread,
Apr 20, 2019, 4:07:54 AM4/20/19
to rubyonra...@googlegroups.com
Hi All,

The issue gotbredolved after I increase the RAM size to 4GB from 1GB.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
regards,
Loganathan

Sent from handheld device.
Reply all
Reply to author
Forward
0 new messages