2

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.

2
  • 1
    Keeps resetting when? At reboot? Every hour? Randomly? Sep 23, 2013 at 8:22
  • 1
    @gladoscc - Did you figure this out in the end?
    – UpTheCreek
    Dec 9, 2013 at 11:21

4 Answers 4

1

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"
1
  • 1
    I'm using forever to start the program.
    – apscience
    Sep 23, 2013 at 14:41
0

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

1
  • No. I don't have selinux.
    – apscience
    Sep 23, 2013 at 10:20
-1

Add ulimit -n 10240 to /root/.bashrc

3
  • This'll affect forever / node.js?
    – apscience
    Sep 23, 2013 at 14:41
  • 1
    It will persist forever but only affect things running in bash using root's profile and executing the .bashrc. Sep 24, 2013 at 1:53
  • You shouldn't really be running node as root in production
    – UpTheCreek
    Dec 9, 2013 at 12:39
-1

The same problem exists in Debian 8, when Im running Redis via the init script it came with. Lost 16 hours writing configs & rebooting trying to get past the limit of 1020 connections running as non-root. Im going to run it as root. AFAIK the apache server is working this way: starts as root, sets the process limits & drops the uid to www-data.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .