Using ulimit -n i am able to set per shell based maximum open files limit

To make this value persistent i am able to edit this is in /etc/security/limits.conf and restart the ubuntu 12.10 box, here is the configuration

*               soft    nofile          10240
*               hard    nofile          10240
root            soft    nofile          10240
root            hard    nofile          10240

but the above value is not getting applied to memcached service, how to make "max open files 10240" to memcached service.

even after setting limits.conf the memcached is still showing

xx@xx:~$ ps aux|grep mem
mysql     2044  0.0  0.0 327436  1260 ?        Sl   17:09   0:00 /usr/bin/memcached -vv -m 256 -p 11211 -u mysql -l

xx@xx:~$ cat /proc/2044/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             30402                30402                processes
Max open files            1024                 1024                 files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       30402                30402                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

please let me know how to increase "max open files" for memcached service

  • Did you figure it out eventually? Also did you check the limit for other processes?
    – HRJ
    Oct 5, 2013 at 19:48

2 Answers 2


In the memcache config set the max open connections using:

-c 10240

You can check if this is actually necessary or not by checking on listen_disabled_num when running:

echo stats | nc localhost 11211

You should see that value above 0 if max connections are an issue.


It seems memcached process is started by mysql user. Try to explicitly add rules in limits.conf to this user (* should apply to all users except root, but it doesn't cost much to try...).

mysql            soft    nofile          10240
mysql            hard    nofile          10240

Also I think those limits are only applied if PAM loads them. Check if you have the following line in /etc/pam.d/common-session

session required pam_limits.so

If not add it at the end. After this you may need to reboot to see the changes applied.

  • I did the mentioned steps 1) adding mysql line to limits.conf 2) added pam_limits.so to common-session file 3) rebooted the box, still the cat /proc/<pid of memcached>/limits is showing 1024 as max open files, i am trying this on ubuntu 12.10. Please let me know if there is anything else I can try to increase max open files for memcached service May 24, 2013 at 3:03
  • 1
    This is wrong. Pam is not used for services.
    – kagronick
    Mar 11, 2017 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.