4

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       
unlimited
$ ulimit -n      
65535

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?

jscott
  • 24,484
  • 8
  • 79
  • 100
kidcapital
  • 847
  • 2
  • 8
  • 10

2 Answers2

3

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.

justarobert
  • 1,869
  • 13
  • 8
  • 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 01 '11 at 09: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 01 '11 at 18:06
2

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.

rvs
  • 4,125
  • 1
  • 27
  • 31