‘Too Many Connections’ MySQL Error From Sites on 1&1 Dedicated Server

October 10th, 2013 - Posted by Steve Marks to Server Management, Web Development.

It’s a developers worst nightmare to look at one of their sites and an error appear like so:

Error connecting to MySQL server: Too many connections

This is exactly what happened to me last week when, not only a single site went down with this error, but every website on the server. Fortunately there was only a couple of sites hosted on this server, but never-the-less, it still meant all hands on deck to fix the problem.

A bit of background

A large site we manage was on shared hosting and was just getting too big. We decided to move it over to it’s own dedicated server so it had it’s own environment and that it’s continued growth wasn’t an issue.

We went for a Linux based package from 1&1 with 1,000 GB of disk space (this will become relevant a little later on) and was able to migrate the site without a hitch. It was about a week later on a Sunday morning when the errors mentioned above started to show.

Identifying the problem

If an effort to get the server up and running and again as quickly as possible, my initial reaction was to reset the number of database connections by restarting the MySQL service. The service stopped but failed to restart again. Not only did we now have errors on the site, we also had a database service that just wouldn’t start.

Fortunately, from experience in the past, I knew this could be the result of a full hard disk. This seemed unlikely since it was a brand new server with very little on it, but I checked anyway by running the following command:

$ df -h

The above can be used to obtain a summary of how much disk space is remaining in each partition. The ‘-h‘ on the end makes it ‘human’ by converting bytes to gigabytes and so forth. The output was as follows:

Note the partitions down the left? The one I was interested in was the third one down, the one mounted on ‘/var‘. As you can see, it’s use is 97%, with a total size of 4GB.

Hang on a second… only 4GB? But the servers hard disk is 1,000GB. Where are the other advertised 996GB?

The solution

After a bit of research it turns out that you need to manually increase the partitions logical volume sizes and allocate disk space to them. The link below from the 1&1 Help Center demonstrates how to do this:

How can I increase a logical volume?

After performing the step above, I was then able to restart the MySQL server successfully and the hosted sites came back to life.

I’m not sure why they only allocate 0.4% of the total disk space to each partition by default, and I’m not sure if this is something specific to 1&1’s dedicated servers only. I do know however that I’ll be keeping a closer on the amount of available disk space from now on.

This entry was posted on Thursday, October 10th, 2013 at 12:34 pm by +Steve Marks and is filed under Server Management, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (0)

No comments have been left yet. Be the first