Forums

502-backend

I am getting this error on one route of my web app. I made multiple mods to a working program and tested it locally, all was fine.

I am not getting any info in the error or server logs.

Is there anywhere else I should be looking?

It's strange that that should happen on one part of your site, but not all of it. The only explanation I can think of is if your code is causing a total crash -- causing python to exit completely.... Is that at all possible?

Yes, possible, but the code works fine on my laptop.

I assume I have missed a file from my git repository or need to install a module, but was hoping for a clue from the logs.

Let us know if you find anything. As a last resort, you can try deleting your web app and creating a brand new one (make sure to back up your web2py apps, so you can restore them...)

Now working, though I am still rather unsure what caused it.

@app.route("/list/<supermarket>", methods=["GET", "POST"])
def lists(supermarket):

    print "In lists with", supermarket

The print line was for debugging before the meat. If supermarket was TSCO, the print statement was not executed, the app crashed and nothing was written to the logs. If the supermarket was TSCOaaa or Tsco, the print statement was executed.

I stopped passing uppercase supermarket codes and it now works.

No idea why.

Very odd. It's probably better to print your debugging to the standard error stream (eg. print >> sys.stderr, "blah") instead of standard output like you're doing there, but I can't see any reason why your code would crash.

I guess so long as it works now that's OK... but if it starts happening again then do let us know.

This problem is back.

@app.route("/list/<supermarket>", methods=["GET", "POST"])
def lists(supermarket):

    print >> sys.stderr,  "In lists"
    sys.stderr.flush()

/list/abcdef

is routed fine through my function.

/list/tsco crashes the web app.

I don't understand why I get nothing in the error or server logs to help me find the bug when it crashes. The print statements make it to the error log when it does not crash.

Any ideas why I am not getting anything in the logs?

Which one of your web apps is it? (If you'd rather keep the details private, just use the "Send feedback" message at the top of the page to send me a message.)

Just a note to say we've taken this discussion private -- if there's something generally useful that comes out of it (eg. if we discover a bug in PythonAnywhere) then I'll post it here.

We think the problem was that the 502 page was being cached by thefrugleguru's browser. That sounds like a bug on the PythonAnywhere side -- the 502 page should have expiry headers and a status code set so that it's never cached. In investigations since then we've found one possible cause, so our next release will fix that and hopefully the page won't be cached for anyone else after that :-)