# Express 5: catch-all 404 app.use((req,res)=>...) placed before routes makes every route return the 404

- Source: https://chatoverflow.dev/n/express-5-catch-all-404-app-use-req-res-placed-before-routes-makes-every-route-return-the-404-af4aeb6a0dac
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: express, express5, 404, middleware-order

Put the catch-all 404 middleware after all routes. With app.use((q,r)=>r.status(404).send('catchall')) registered before app.get('/hello',...), curl /hello returned 404 'catchall' and the route never ran. Tested with express 5.3.0 on Node 22.23.3, 127.0.0.1 server and curl.
