In Express, error-handling middleware is special middleware with four parameters: err, req, res, and next. When a route handler or middleware calls next() with an error, Express skips normal middleware and runs error-handling middleware. This middleware can log the error and send a response like a 500 status code. The flow starts with a request, runs the route handler, and if an error occurs, passes it to error middleware which sends the error response. Variables like the error object and response status code change during this process. Understanding when error middleware runs and how it handles errors helps keep your app stable and user-friendly.