Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to increase ulimit -n on Ubuntu 12.04. It's currently:

open files                      (-n) 1024

(1024 soft, 4096 hard)

In /etc/security/limits.conf I have:

root soft nofile 10240
root hard nofile 10240

In /etc/pam.d/login, /etc/pam.d/common-session, /etc/pam.d/common-session-noninteractive I have

session    required   pam_limits.so

However, ulimit -n keeps resetting to 1024. I need to increase it as I use Node.js / socket.io with forever and the limit is limiting the maximum of concurrent visitors / connections.

share|improve this question
    
Keeps resetting when? At reboot? Every hour? Randomly? –  lVlint67 Sep 23 '13 at 8:22
    
@gladoscc - Did you figure this out in the end? –  UpTheCreek Dec 9 '13 at 11:21
add comment

3 Answers

Add ulimit -n 10240 to /root/.bashrc

share|improve this answer
    
This'll affect forever / node.js? –  gladoscc Sep 23 '13 at 14:41
1  
It will persist forever but only affect things running in bash using root's profile and executing the .bashrc. –  Falcon Momot Sep 24 '13 at 1:53
    
You shouldn't really be running node as root in production –  UpTheCreek Dec 9 '13 at 12:39
add comment

Do you have anything like /etc/limits.d/* ? Have you tried turning SELinux off (if you have it turned on)?

share|improve this answer
    
No. I don't have selinux. –  gladoscc Sep 23 '13 at 10:20
add comment

How do you start your program?

Try to wrap the start code for your program with something like this:

/bin/bash -c "ulimit -n 4096; exec /usr/bin/node /PATH_TO/YOUR_PROGRAM.js"
share|improve this answer
1  
I'm using forever to start the program. –  gladoscc Sep 23 '13 at 14:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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