Help for owners
My app's backend keeps failing with 500 errors
Short answer
A 500 error means the server hit an unexpected problem and could not finish the request. It is a server-side fault, not something your customers did. Write down when it happens and what people were doing, do not restart or change anything yourself, and ask your developer or host for the error log.
Does this sound like your situation?
- Some screens in my app fail or show a generic error, and others work.
- It happens at random: the same action works one minute and fails the next.
- Customers say orders, logins or forms fail, but my developer says everything looks fine.
- The errors started after an update, a busy day or a change at my host.
- I see the words Internal Server Error, or the app just says something went wrong.
Why does this happen?
A 500 is a catch-all for server trouble
The standard description of a 500 error is a generic response for an unexpected condition on the server. It places the problem with the server owner, not with the visitor. The code does not say what went wrong, so the real cause is only found in the server's error log.
Confirmed by developer.mozilla.org
Typical causes are configuration, memory, unhandled errors and permissions
The same reference lists improper server configuration, the server running out of memory, unhandled exceptions in the code and improper file permissions. Which one applies to you depends on your stack and can only be told from the logs.
Confirmed by developer.mozilla.org
A database or another service behind the app is failing
Often the app itself is fine, but the database, a payment service or an email service it calls is slow or refusing connections. The app then fails on the requests that need that service, which looks random from outside.
Random failures often mean the server is overloaded
If errors cluster at busy times, the server may be running out of memory or connections. Restarting hides it for a while and it returns.
Nobody is watching the errors
Many apps have no error alerts at all. The first sign is a customer complaint, and by then the log that explains it may have been overwritten.
What can I do about it today?
- Write down the patternNote the time, the screen or action, the device and who was affected. A list of five examples helps more than a long description.
- Take a screenshot of the errorInclude the date and time on the screen if you can. Do not retry the same payment or order over and over.
- Ask your developer or host for the error logAsk for the server log around those times. You do not need to read it yourself, only to make sure it is saved and sent to whoever will look.
- Do not restart or change settings yourselfA restart can wipe the very evidence that shows the cause. Leave servers, databases and settings as they are unless your developer asks you to.
- Tell affected customers what you knowA short note that you know about the problem and are looking into it reduces repeat attempts and support messages.
When should I bring someone in?
- The errors affect payments, orders or logins.
- They keep returning after a restart, or got worse over days.
- Your developer cannot say what the cause is, or there is no log to look at.
How do I handle it?
- Secure the logs firstBefore touching anything, I make sure the server and application logs from the failing period are saved.
- Group the errors by causeI match failing requests to their log entries and sort them: code faults, database trouble, outside services, or a lack of memory and connections.
- Fix the cause, not the symptomI make the smallest change that removes the cause and test it on a copy first. Changes to production are made after a backup, with a tested rollback.
- Add alerts so you hear firstI set up error alerts and a simple health check, so the next failure reaches you and me before your customers.
The price depends on what I find, so I quote in writing after a short discovery call. Tell me what is happening and I reply within 24 hours.
What do owners ask about this?
Is a 500 error my customers' fault?
No. The standard reference describes it as a server-side condition that needs the server owner or administrator to investigate.
Why does it only fail sometimes?
Usually because the failure depends on something that varies: the data in the request, the load on the server or a service the app calls. The log shows which.
Can it be fixed without rebuilding the app?
Most 500 errors have a specific cause that can be fixed in place. I tell you in writing if the cause turns out to be deeper.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Found a mistake? Tell me.
For your developer: the technical fixes
502 Bad Gatewaynginx 502 Bad Gateway in front of a Node.js app504 Gateway Time-outnginx gives up waiting for the app and returns 504500 Internal Server ErrorLaravel returns 500 Internal Server Error on ApacheFatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)PHP Fatal error: Allowed memory size of 134217728 bytes exhausted