Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "too many open files" in MySQL?

Tags:

mysql

I am very frequently getting this error in MySQL:

OS errno 24 - Too many open files

What's the cause and what are the solutions?

like image 900
Naresh kumar Sanda Avatar asked May 16 '17 16:05

Naresh kumar Sanda


2 Answers

You probably have a connection leak in your application, that is why open connections are not closed once the function completes it's execution.

I would probably look into the application code and see where the connections/preparedstatement (if it's java) objects are not closed and fix it.

A quick workaround is to increase ulimit of the server (explained here) which would increase number of open file descriptors (i.e. connections). However, if you have a connection leak, you will encounter this error again, at later stages.

like image 92
Darshan Mehta Avatar answered Sep 30 '22 12:09

Darshan Mehta


I faced the same problem and found a solution on another stackoverflow-question.

By running the following snippet with Bash:

ulimit -n 30000
like image 44
Geoffroy Avatar answered Sep 30 '22 13:09

Geoffroy