# Command failed with exit code 137

**URL:** <https://answers.netlify.com/t/command-failed-with-exit-code-137/95042>\
**Category:** Support\
**Tags:** nextjs, building\
**Created:** [June 22, 2023, 10:19am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042 "2023-06-22T10:19:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kapiltez](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/kapiltez/32/44278_2.png) [@kapiltez](https://answers.netlify.com/u/kapiltez)\
**Post date:** [June 22, 2023, 10:19am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/1 "2023-06-22T10:19:48Z")

</div>

Hi team, I am getting following error for my site while building build.I’m running the same command on my local and I don’t encounter the same issue. My sites info and error logs are as following:

- netlify site name: `plenty-network-temp-development`

- deploy link: [Netlify App](https://app.netlify.com/sites/plenty-network-temp-development/deploys/64941b1ffa46f400082963af)

- Build logs(error):

3:29:38 PM: info - Generating static pages (3/12)  
3:29:40 PM: Killed  
3:29:40 PM: ​  
3:29:40 PM: “build.command” failed  
3:29:40 PM: ────────────────────────────────────────────────────────────────  
3:29:40 PM: ​  
3:29:40 PM: Error message  
3:29:40 PM: Command failed with exit code 137: CI=false npm run build ([Search results for '"non-zero exit code: 137"' - Netlify Support Forums](https://ntl.fyi/exit-code-137))  
3:29:40 PM: ​  
3:29:40 PM: Error location  
3:29:40 PM: In Build command from Netlify app:  
3:29:40 PM: CI=false npm run build  
3:29:40 PM: ​  
3:29:40 PM: Resolved config  
3:29:40 PM: build:  
3:29:40 PM: command: CI=false npm run build  
3:29:40 PM: commandOrigin: ui  
3:29:40 PM: environment:  
3:29:40 PM: - CI  
3:29:40 PM: - NEXT\_PUBLIC\_RPC\_MAINNET  
3:29:40 PM: - NEXT\_PUBLIC\_RPC\_TESTNET  
3:29:40 PM: - NEXT\_PUBLIC\_TZKT\_GHOSTNET  
3:29:40 PM: - NEXT\_PUBLIC\_TZKT\_MAINNET  
3:29:40 PM: - NODE\_OPTIONS  
3:29:40 PM: - REVIEW\_ID  
3:29:40 PM: - NEXT\_PRIVATE\_TARGET  
3:29:40 PM: publish: /opt/build/repo/.next  
3:29:40 PM: publishOrigin: ui  
3:29:40 PM: plugins:  
3:29:40 PM: - inputs: {}  
3:29:40 PM: origin: ui  
3:29:40 PM: package: ‘@netlify/plugin-nextjs’  
3:29:42 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 ([Search results for '"non-zero exit code: 2"' - Netlify Support Forums](https://ntl.fyi/exit-code-2))  
3:29:42 PM: Build failed due to a user error: Build script returned non-zero exit code: 2  
3:29:42 PM: Failing build: Failed to build site  
3:29:42 PM: Finished processing build request in 1m48.307s

My site is using nextjs.

Thank you.

---

<div class="post-metadata">

**Author:** ![nathanmartin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/nathanmartin/32/30845_2.png) [@nathanmartin](https://answers.netlify.com/u/nathanmartin)\
**Post date:** [June 22, 2023, 10:25am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/2 "2023-06-22T10:25:17Z")

</div>

> [@kapiltez](#):
>
> 3:29:40 PM: Killed

@kapiltez Error 137 is likely to be a memory issue.

See:

> [@\[Support Guide\] What can I do if my build fails for memory-overallocation-related errors?](https://answers.netlify.com/t/support-guide-what-can-i-do-if-my-build-fails-for-memory-overallocation-related-errors/36549):
>
> last updated by Netlify Support Nov 2023 Are you struggling to get your build working? Most build errors are caused by problems in code or data, and for those errors, our best guide / general starting place for debugging build troubles is this one: But, sometimes your build is working fine and suddenly ends with some inscrutable errors that don’t seem to be “about” your code or site even. Perhaps you see an error message like this in your builds? 2:28:35 PM: \<--- Last few GCs ---\> 2:28:35…

---

<div class="post-metadata">

**Author:** ![kapiltez](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/kapiltez/32/44278_2.png) [@kapiltez](https://answers.netlify.com/u/kapiltez)\
**Post date:** [June 22, 2023, 10:34am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/3 "2023-06-22T10:34:26Z")

</div>

How can I know if memory getting full or is there any issue? Can you help me with proper debugging?

---

<div class="post-metadata">

**Author:** ![kapiltez](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/kapiltez/32/44278_2.png) [@kapiltez](https://answers.netlify.com/u/kapiltez)\
**Post date:** [June 22, 2023, 10:35am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/4 "2023-06-22T10:35:37Z")

</div>

If it’s memory issue, how can I fix in my case for nextjs app?

---

<div class="post-metadata">

**Author:** ![nathanmartin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/nathanmartin/32/30845_2.png) [@nathanmartin](https://answers.netlify.com/u/nathanmartin)\
**Post date:** [June 22, 2023, 10:36am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/5 "2023-06-22T10:36:09Z")

</div>

@kapiltez Did you read the support guide that I linked to?

---

<div class="post-metadata">

**Author:** ![kapiltez](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/kapiltez/32/44278_2.png) [@kapiltez](https://answers.netlify.com/u/kapiltez)\
**Post date:** [June 22, 2023, 10:41am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/6 "2023-06-22T10:41:55Z")

</div>

yes tried with increasing momory size in env var as well. Since my app is in nextjs, shall I use gatsby as suggested in above blog?

---

<div class="post-metadata">

**Author:** ![nathanmartin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/nathanmartin/32/30845_2.png) [@nathanmartin](https://answers.netlify.com/u/nathanmartin)\
**Post date:** [June 22, 2023, 10:44am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/7 "2023-06-22T10:44:31Z")

</div>

@kapiltez No, I think you’ve misunderstood that support guide.

The guide says that Gatsby is one of the build systems that most encounters memory issues.

It provides suggestions for how to increase the memory (which can only be increased so far), or to reduce your usage.

If you think you are hitting a memory issue you should optimize your build… change it so that it uses less memory.

---

<div class="post-metadata">

**Author:** ![kapiltez](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/kapiltez/32/44278_2.png) [@kapiltez](https://answers.netlify.com/u/kapiltez)\
**Post date:** [June 22, 2023, 10:47am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/8 "2023-06-22T10:47:06Z")

</div>

on vercel it’s perfectly fine. Isn’t there any other way to increase the memory?

---

<div class="post-metadata">

**Author:** ![nathanmartin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/nathanmartin/32/30845_2.png) [@nathanmartin](https://answers.netlify.com/u/nathanmartin)\
**Post date:** [June 22, 2023, 11:01am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/9 "2023-06-22T11:01:59Z")

</div>

@kapiltez I couldn’t say, as I work exclusively with my own static site generator and I’ve never run into a memory issue.

You could try googling around, or wait and see if Netlify’s support crew have any information to add.

---

<div class="post-metadata">

**Author:** ![gualter](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/gualter/32/35068_2.png) [@gualter](https://answers.netlify.com/u/gualter)\
**Post date:** [June 22, 2023, 11:50am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/11 "2023-06-22T11:50:39Z")

</div>

hi @kapiltez

I’ve replied to your helpdesk thread as well.

TLDR: some builds for that same context (a deploy preview for PR#993 against your prod branch) are failing since you’re doing something resource heavy.

Your production builds are not failing due to memory, what changed on this particular PR?

Thanks!

---

<div class="post-metadata">

**Author:** ![kapiltez](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/kapiltez/32/44278_2.png) [@kapiltez](https://answers.netlify.com/u/kapiltez)\
**Post date:** [June 22, 2023, 2:38pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-137/95042/12 "2023-06-22T14:38:40Z")

</div>

sure thing. A couple of stuffs got updated in code.
