Stop showing stack traces and error details to visitors
When something breaks, what does a visitor see? If it is a wall of code with file paths, library versions or a database name, you are handing out a map of your app. Visitors want a plain message and a way to continue.
How to check
- Cause an error on purpose: open an address for a record that does not exist, such as
/orders/99999999. - Submit a form with an odd value.
- Read what comes back. It should be a short message, with no file paths, no library names and versions, and no database text.
How to fix it
- Express: set
NODE_ENV=production. The default error handler shows the stack trace only outside production.
Add your own handler so visitors see a plain message and the details go to your logs:
Express
app.use((err, req, res, next) => {
console.error(err); // details stay in your logs
res.status(500).send("Something went wrong. Please try again.");
});- Next.js and other frameworks: use the framework's error page and keep development mode off in production.
- APIs: return a short error message and a code, not the exception text.
What a good error page has
- A plain sentence saying something went wrong.
- A button to try again or go home.
- A way to contact you.
- Nothing about your code or your servers.
Want this checked on your app?
In a run, App Investigators triggers errors on purpose and reports when a page shows technical details like stack traces to visitors.
We email you once when a spot opens. No spam, and you can ask us to remove you any time at support@appinvestigators.com.
Related guides
- Check for exposed .env files, source maps and open folders
- Vibe coding security checklist: what to check before you launch
- Fix a 404 page that returns 200 (soft 404)
Last updated 2026-11-24. This guide describes common problems and fixes. It is not a guarantee that any app is secure or free of bugs.