Skip to main content

Errors for Expresss

Express error handling is the way an app catches failures and responds consistently. An error-handling middleware has four parameters, err, req, res and next, and is registered after the routes. Synchronous throws are caught automatically, while async errors must be forwarded with next or handled by a wrapper.

Stage: Reliability · Part of the Express roadmap · Last reviewed 19 November 2026

What to learn in Errors

Errors interview questions

How does Express recognise an error-handling middleware?

By its signature of four parameters, err, req, res and next. Express calls it when next receives an argument or a handler throws synchronously. It must be registered after the routes and other middleware it should cover.

Why can an async route handler crash the process or hang the request?

In Express 4 a rejected promise in an async handler is not caught automatically, so the error is unhandled. Wrap the handler or use try/catch with next(err). Express 5 forwards rejected promises to the error handler for you.

Where Errors fits in the Express roadmap

Errors belongs to the Reliability stage (beginner level). Handle failure.

Back to the full Express roadmap