Express 5 · Error handling

Handle 404s

Add a catch-all after your routes.

app.use((req, res) => {
  res.status(404).json({ error: "Not found" });
});

Official Express 5 documentation

More error handling commands

All error handling commands · Express 5 cheatsheet

Was this page helpful?