FG
โ˜๏ธ Cloud & DevOpsAmazon

"EMFILE - too many open file" error

Freshover 1 year ago
Mar 14, 20260 views
Confidence Score76%
76%

Problem

Previous issue: #3249, #10706 This is a meta-issue to gather all reports about the following error: [code block] This is a very tough issue to solve because it happens randomly. It is caused by having too many files open _on the whole machine_ (not just the `serverless` process). A possible root cause could be synchronous usage of the `fs` API. A solution might be to use `graceful-fs` and/or the async API to access the filesystem. We use `graceful-fs` and reduced the use of sync calls in Serverless Framework to a minimum, but some plugins might not. We're trying to identify which plugins might cause the issue. Workarounds This isn't ideal, but it is possible to increase the limit of files open on Linux and macOS with `ulimit` (https://stackoverflow.com/a/21070580/245552), but not on Windows. If you have information about more workarounds, please post them here and we'll update the issue. How to help? - Add a ๐Ÿ‘ on this issue (so that we can estimate the impact) - Investigate if some plugins might benefit from using `graceful-fs` and/or async filesystem calls - Fill the following form and post it as a comment: [code block] Let's try and see if there's a pattern (e.g. a plugin that comes up often).

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
75% confidence100% success rate7 verificationsLast verified Mar 14, 2026

Solution: "EMFILE - too many open file" error

Low Risk

Hello, I got the EMFILE error when launching the serverless "deploy" script. I used graceful-fs like this to solve the issue : 1. install graceful-fs: `npm install graceful-fs` 2. go to file: `node_modules/serverless/lib/plugins/package/lib/zip-service.js` 3. replace this line : `const fs = BbPromise.promisifyAll(require('fs'));` by this: [code block]

75

Trust Score

7 verifications

100% success
  1. 1

    Hello, I got the EMFILE error when launching the serverless "deploy" script. I u

    1. install graceful-fs: `npm install graceful-fs` 2. go to file: `node_modules/serverless/lib/plugins/package/lib/zip-service.js` 3. replace this line : `const fs = BbPromise.promisifyAll(require('fs'));` by this: [code block]

Validation

Resolved in serverless/serverless GitHub issue #10944. Community reactions: 36 upvotes.

Verification Summary

Worked: 7
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

serverlesslambdaawsbug