how can I get a larger stack trace from a node.js network error?


I get this error:

Error: accept EMFILE
at errnoException (net.js:769:11)
at TCP.onconnection (net.js:1017:24)

from a node.js app. Can I get a line number of my code that calls TCP.onconnection in the first place?

Problem courtesy of: Andrew Arrow


No you can't, because your code isn't calling TCP.onconnection. That's an event handler, so an event is triggering it. This is one of the reasons event-based programming is difficult to debug.

I think you'll have some luck looking into what that error means, though. Some searching reveals that you're hitting a file descriptor limit, which can probably be increased (but that would be OS-dependent, so I can't tell you how without more info).

Solution courtesy of: Aaron Dufour


EMFILE occurs when there is too many files are opened in the system. To increase this limit, look at Linux Increase The Maximum Number Of Open Files / File Descriptors (FD) or revise your code that you close the opened connections when their job is finished. Or If you need too many files open, just increase this value to a reasonable size.

Discussion courtesy of: Mustafa

This recipe can be found in it's original form on Stack Over Flow.