Forums

Error code: 502-backend - Need Help!

Something went wrong :-(

This website is hosted by PythonAnywhere, an online hosting environment. Something went wrong while trying to load it; please try again later.

If this is your PythonAnywhere-hosted site, and you just reloaded it, then the problem might simply be that it hasn't loaded up yet. Try refreshing this page and see if this message disappears.

If you keep getting this message, you should check your site's server and error logs for any messages — you can view them from the Web tab inside PythonAnywhere.

If there's nothing in the logs, and you're sure your site is OK, then it might be a problem on our side. Drop us a line at support@pythonanywhere.com, in the forums, or using the "Send feedback" link on the site, quoting the error code below.

Error code: 502-backend

Where are you seeing this error? I just checked your web app and it seems to be running.

Strange its working again, thanks for looking

Sometimes you'll get that error while the web app is reloading -- so if you hit the "reload" button it's safest to wait until the "spinner" icon next to it has stopped before visiting the site. Perhaps that was the problem?

Checking the server logs is also really useful. I was able to uncover some bugs in my code that caused the 502-backend error via the server logs.

Hello, I got the same error message. The error.log is empty but the server log shows:

2014-02-06 13:37:19 announcing my loyalty to the Emperor... 2014-02-06 13:37:36 announcing my loyalty to the Emperor... 2014-02-06 13:41:45 Thu Feb 6 13:41:45 2014 - received message 1 from emperor 2014-02-06 13:41:45 ...gracefully killing workers... 2014-02-06 13:41:45 Gracefully killing worker 1 (pid: 11899)... 2014-02-06 13:41:45 Gracefully killing worker 2 (pid: 11902)... 2014-02-06 13:41:46 worker 1 buried after 1 seconds 2014-02-06 13:41:46 worker 2 buried after 1 seconds 2014-02-06 13:41:46 uWSGI: GAME OVER (insert coin) 2014-02-06 13:41:46 chdir(): No such file or directory [core/uwsgi.c line 1450] 2014-02-06 13:41:46 VACUUM: unix socket /var/sockets/jmfrank63.pythonanywhere.com/socket removed.

Reloading the application has no effect. Any hint what I could do?

P.S.: I am using flask. Additional infos on request.

do you have the app open? close it and reload it.

I did, no difference. Now its 14:10 and the last server log I got is 13:41. No reaction on server.log. error.log is empty. access.log shows my reloads. Any hints?

Sorry, I should have posted here earlier. We're looking into it. Is there any chance that you're doing a run() anywhere in your code? We've sometimes seen problems like this in Flask apps when the process tries to runs its own web server rather than relying on ours.

No, hurry. No I had this in the beginning, but I changed things to your webserver, because I thought you would naturally be having a firewall blocking most of the ports, (which I do appretiate). There is a run.py file, but it only contains one line: from app import app as application

as I removed the app.run().

Everything started after I tried to add a second link to my base.html file in the templates directory.

I reverted to the original version (removing the line) but to no avail. As there is no server log and the error log is empty I have little possibilities to debug.

That's very odd. There's a possibility that someone else's web app on the same machine might have a run() in it, and that could possibly affect other apps on the same machine, so I've bounced that server. Is your site working again now?

Hmm, I did the old comment out trick, to encircle the error. After I got a working app (with limitations of course) I started to comment in again. Except for comment I didn't change anything ??? WTF ??? Now it works again!!! Programming can be so much fun! Nevertheless thanks for your efforts :-)

I reckon it must have been another app on the same server that somehow managed to cause knock-on effects for yours. This isn't meant to be possible, but we're beginning to think there may be a bug in the web stack we're using that makes it possible under certain (unlikely) circumstances. Investigations continue...

I can confirm the same problem, which happend to me durig tha last hour. I had the Error code: 502-backend when trying to load my login app. After I commented out the @login_required view, I got a running app. Now after uncommenting the view again, everything work as it should.

Hmm, I think this must have been something different. None of the servers have had that specific problem this morning.

Sometimes you can get a 502 error if a web app is reloading when you visit it -- normally that will go away if you refresh the page. Might that be what happened?

Indeed I was too hasty when I was visiting the page while the app was reloading. However the Error didn't go away after reloading again for multiple times. I only solved the problem as I said by commenting out and commenting in again.

That's odd. We have heard of cases where for some reason the error message gets cached, we think by the browser. And somehow reloading the web app again from PythonAnywhere fixes the issue, while reloading the page in the browser normally doesn't. If this does happen again, could you try a full force-reload -- Shift-F5 in Chrome and Firefox, or shift-clicking the reload button. If that clears things up then that's the cause. If it's not, then there's something else going on. Either way, do let us know.

Thanks for the hint. I will keep you updated in case it will happen again.

I have this same problems guys, just soon after using redislite for my kvsesssion which was working perfectly....then I started having 502-backend error...what went wrong?

Might your code be starting up extra processes to run as redis servers? If so, then if you're not shutting them down when they're no longer needed, you might run out of processes. I'll check the web server where your code works to see if that's the case.

OK, that definitely seems to have been the problem. You had nine redis servers running on the web server where your app runs, which was stopping the website from starting up. If you need a redis server, I'd recommend you get one from a third-party provider like Redis -- they have free options, and if you configure it to be in AWS/us-east1 then it will be in the same datacenter as PythonAnywhere, so it should be pretty fast.

[edit: RedisLabs has rebranded as Redis; updated link]

hey folks, i am running into this. not using redis or anything fancy. in fact i am newbie so don't know enough to do much. just did git pull and double-checking settings file but i'm still getting 500 error and server log has the loyalty to emperor message? (www.blissrage.com)

The "loyalty to Emperor" message is just our system saying that everything's started up OK. Have you taken a look at the error log? There's a link on the "Web" tab, and the most recent error will be at the end of the file.

I checked that error log first and oddly the entries are days old:

2018-01-06 05:12:51,911: IOError: write error 2018-01-06 05:12:51,912: Error running WSGI application 2018-01-06 05:12:51,912: GeneratorExit

Hmm, that's odd. It looks like your site is a Django one -- what do you see if you set DEBUG to True in the settings.py and reload it?

YOWGA! Turning debug off allowed me to find EXTENDS in jinja tag instead of extends . . . some kind of git snafu on my part ruined snake-casing somehow. Thanks much for the newbie help; may blessings of karmic fairy dust rain upon ye and those masters who had to read this far :-D

Hooray! Glad we got to the bottom of it. And thanks for the fairy dust, much appreciated :-)