Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Express Error: EMFILE, too many open files

Express Error: EMFILE, too many open files


I am getting the following very annoying error:

Error: EMFILE, too many open files '/home/'
at Object.openSync (fs.js:240:18)
at Object.readFileSync (fs.js:128:15)
at View.contents (/home/
at Function.compile (/home/
at ServerResponse._render (/home/
at ServerResponse. (/home/
at /home/
at resolve (/home/
at ServerResponse.expressmongoose [as render] (/home/
at /home/

I believe it is a problem with Express; how can I remedy it? Thanks.

Problem courtesy of: Ian Macalinao


From what I found, it happens when some error happens, and some files aren't closed (of course this is a bug). In my case, node-postgres errors caused (miracleously) depletion of available descriptors. When I removed the code that caused db error, the EMFILE dissapears.

I suppose it could be fixed in the node.js code - it should close file objects when garbage collecting. Though it might happen that these lost file descriptors are still locked alive by something else.

Solution courtesy of: sergeych


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Express Error: EMFILE, too many open files


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription