In Ubuntu 9 I am receiving a message on my server that says:

(node) Hit max file limit. Increase "ulimit -n"

However, typing commands in the terminal reveals the following:

$ ulimit       
$ ulimit -n      

And a netstat reveals I only have ~1000 connections open.

How is it possible I am hitting my limit of 65535 despite netstat saying I have 1000 active connections? Does anyone see a server config issue I might be overlooking or have tips for debugging further?

  • 1
    Where are you seeing this message ? – user9517 May 1 '11 at 8:31

ulimit -n displays the maximum number of open file descriptors, not the maximum number of network connections. You may want to use lsof -p <PID_OF_node.js> to figure out what files it has open. My guess is that your node.js code has some logic flaws.

  • Actually, opened network socket IS file descriptor as well. So ulimit -n controlls how many local files + network sockets + any other descriptors could be opened by a single process/user. – rvs May 1 '11 at 9:43
  • 1
    True. I mentioned open files because we already know at most how many network sockets the process has open; at any rate, lsof will display them all. – justarobert May 1 '11 at 18:06

Typing ulimit -n in terminal shows current limit, effective to your current session. If you've changed limit after compaining daemon start, limits for that daemon was not affected. So you'll need to stop/start daemon. But make sure that limits are not chaning in daemon's init script.

Also, you might want add something like this:

*               soft    nofile          2048
*               hard    nofile          2048

to /etc/security/limits.conf, so you don't have to ulimit -n manually each time.

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.