Node.js: [UnhandledPromiseRejection] — This error originated either by throwing inside of an async function without a catch block
A promise rejected and nothing handled it; since Node 15 this crashes the process.
Meaning
The real error is the one printed with the rejection (the reason). Missing await, missing .catch(), or async callbacks passed to APIs that ignore returned promises (forEach, event emitters, Express 4 handlers) are the usual sources.
Common causes
- Async function called without await or .catch()
- async callback in
forEach/setTimeout/ event listener - Express 4 async route without error forwarding
- Promise.all where one promise rejects unhandled
⚡ Quick fix
- Read the reason printed with the warning — that is the actual bug
- await or .catch() every promise
- Use
for…ofwith await instead of forEach(async) - Express 4: wrap async handlers or upgrade to Express 5
Detailed fix by platform
Node.js
- Last-resort logging (still fix the source):javascript
process.on('unhandledRejection', (reason) => { console.error('Unhandled rejection:', reason); process.exitCode = 1; }); // Express 4: const wrap = fn => (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next); app.get('/users', wrap(async (req, res) => res.json(await db.users())));
How to diagnose
- Reason — What error/stack is attached?
- Caller — Which call is missing await/catch?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026