ERR_UNHANDLED_REJECTION in Node.js — What It Means and How to Fix It

What the Node.js/npm error ERR_UNHANDLED_REJECTION means and how to resolve it.

Published October 26, 2026

Modern Node terminates the process with ERR_UNHANDLED_REJECTION when a promise rejects and nothing handles it.

What it means and why it happens

The fix is to handle rejections with try/catch or .catch() everywhere you start async work.

Read the full message: it names the file and line where the problem was detected, which is the best place to start.

What you see

run the code
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block...] code: 'ERR_UNHANDLED_REJECTION'

Practical examples

Code that triggers it

setTimeout(async () => { throw new Error('x') }, 0)

The fix

setTimeout(async () => {
  try { await work() } catch (e) { console.error(e) }
}, 0)

Top-level handlers

process.on('unhandledRejection', (r) => { console.error(r); process.exit(1) })

Common mistakes

  • Fire-and-forget promises without catch.
  • Async callbacks in event emitters.
  • Swallowing errors without logging.

Key takeaways

  • ERR_UNHANDLED_REJECTION: Modern Node terminates the process with ERR_UNHANDLED_REJECTION when a promise rejects and nothing handles it.
  • Read the message and the line number first.
  • Fix the cause, don't just silence the error.

FAQ

--unhandled-rejections flag?

Node supports modes like warn or strict, but handling errors is the proper fix.

How do I find which line caused ERR_UNHANDLED_REJECTION?

The error message and stack trace show the file and line; start there and work backwards.

More JavaScript articles