MySQL error #1135: Can’t create a new thread (errno 11).

This error was the bane of my life for a while, and it was very hard to get a definitive answer as to what was causing it, I hope this saves you some trouble.

My website occasionally got large traffic spikes, and at the top of these peaks, I would start to see errors like these:

MySQL error #1135: Can’t create a new thread (errno 11). If you are not out of available memory, you can consult the manual for a possible OS-dependent bug.

I looked in the my.cnf file on the db server and looked at the open files limit, because a process is counted as an open file, but it seemed fine:

[mysqld_safe]
open-files-limit=10240

I also checked that maximum connections was high enough, it was at 2048.

What the open-files-limit in my.cnf files does is it tells the init script to use ulimit to whatever number you put in there.

After a lot of digging around various places, and much frustration, I discovered that by default linux has a hard limit of 1024 open files for all non super-users, so even though I had set a high open-files-limit, it was capped at 1024 by the OS. I also discovered how to raise it;

/etc/security/limits.conf

This file is used by PAM to set things like maximum processes, max open files, memory usage etc and these limits can be set on a per-user basis, so I added these lines:

mysql soft nofile 4096
mysql hard nofile 4096


and restarted MySQL. BAM! That did the trick.
One more thing to make sure of is that the su pam config file (/etc/pam.d/su) is using pam_limits.so, as that is the pam module which enforces limits.

Good luck!
-Jonesy

No related posts.

Have a computer problem? Ask in our SUPPORT forum!

Receive Discounted Software

No bull. Want cheap discounts for common software products?
  • AntiVirus
  • Video editing tools
  • Web development tools
  • Registry Cleaners
  • Computer speed boosters!
Our editors get these products sent to us WEEKLY for review.

WE WANT TO PASS THESE DISCOUNTS ON TO YOU! (We honestly don't need them)

So whack your email in the box below and when we receive stuff we'll forward it to you! Its that simple.


8 Responses to “MySQL error #1135: Can’t create a new thread (errno 11).”

  1. Jamsi says:

    I need me some of this large traffic spike u talk about.

  2. Mark says:

    Appreciate this posting! I forgot about those pam limits, this is just what I needed, thanks for reminding me. I added (without quotes)

    “session required /lib/security/pam_limits.so”

    to “/etc/pam.d/login”

  3. Dave says:

    is a simular fix for a win box?
    i have been trying to find a fix for some time, this is the first i see of anything resembling one.

    win box runing server 2003.
    4g ram

    have actually planed to format and change it centos, but it apears the issue is not completly the os.

  4. David says:

    Question; without the addition of the pam_limits.so to pam.d/login, wouldn’t there effectively be no limits? Or are there always limits by default, you then have to include the pam limits file before you can raise them?

  5. Jonesy says:

    You’re absolutely right, David, if you disabled the pam_limits.so module you would have no limits.

  6. Jonesy says:

    Dave, I’m afraid this solution is very Linux-specific, the operating system architectures are quite different, and PAM is not present in windows.

    It is _possible_ that windows has similar limits, but I have no idea of how one would go about finding them or raising them (if they exist!)

  7. [...] $file3 HTTP/1.0r … domain1,80,$errno,$errstr,30);if(!$fp1){print Error: $errstr [$errno] …MySQL error #1135: Can't create a new thread (errno 11).MySQL error #1135: Can't create a new thread (errno 11). If you are not out of available memory, you [...]

  8. MeganBt27 says:

    A lot of various studens get know some keys of term paper titles creating, nevertheless this does not mean they are able compose superior quality essay papers, but a essays online service would help to write the good essay of A+ quality and improve writing skills of students.

Leave a Reply