Troubleshoot Google App Engine 500 internal server error
Is there any way to properly troubleshoot GAE 500 server errors? I know I can check from console.developers.google.com -> Monitoring -> logs, but they do not tell much. Only same thing that I can get from the browser network response 500 internal server error.
What I am looking for is the similar log to apache.log or php.log that would actually print a stacktrace of an error or an exception that happened in app.
Solution 1:
The previous answers are out of date now (some three years later). Look for the Error Reporting panel in the google cloud platform dashboard.
You will get a stack trace to the problem in your code (if the problem is in your code and I suppose you probably need to be logging errors to std err). A stack trace should help you debug a 500 error. Here's a stack trace that I just received ...
ImportError: No module named flask_assistant
at <module> (/base/data/home/apps/f~XXXX/20180209t180735.407529010683953771/main.py:31)
at LoadObject (/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:85)
at _LoadHandler (/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:299)
at Handle (/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:240)
That's how to get a stack trace in the event of a 500 error.
Solution 2:
There's unfortunately no straightforward answer to this.
Normally, a 500 is something about which you cannot do much, as it's an error internal to the Google servers. The most we suggest is to have an exponential backoff to your requests, so that our infrastructure can "correct" the issue itself (which it usually does, and does pretty quickly).
Sometimes, some errors will throw 500 for specific behaviors (like sending a wrong format of file or a wrong variable type to a specific product). In these case, the error should be clearer. If it isn't, try to gather as much info as possible and then post it on our Issue Tracker that this error could be phrased with more info than "500"