Website Not Working suddenly! No code changes made.

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, in the forums, or using the "Send feedback" link on the site, quoting the error code below.

Error code: 502-backend

I have same problem

Try to reload your site.

I had the same issue and reloading worked. Thanks!

Hi there,

We did see some server problems overnight ~7hrs ago and ~17hrs ago. We believe we have identified the root cause and have mitigated it. Was this the time that you started experiencing problems?

Hi There! Website not working suddenly. I haven't made any changes still getting error with Error Code: 502-backend. All files are missing. Started getting this error around 10.00AM IST.

We had trouble with one of your machines. It should be fixed now.

Yep... It was fixed. Thanks a lot for addressing and reverting back.

Thanks for confirming that!

Hi all, is anyone else still having issues? My site seems to be "flaky" I'm getting what seems to be random 500's. If i keep reloading the page, it finally loads.

I've tried reloading my app. I did notice once on the webapp page, the traffic graph was missing, if that helps anyone troubleshoot.

Luckily, my customer is on holiday today :)


@nichos -- if you see 500 errors (and not 502 or 504), you should see a trace of them in your error logs, could you check that?

@pafk thanks - Before checking the logs I hit the site a few times and haven't seen the issue again. Customer hasn't reported anything either.

Thanks for the reply, if it happens again, I'll grab the logs.

Sure, thanks for confirming everything works now.

@pafk sorry to bump an old thread, let me know if you prefer i open a new one. I think I know what my problems were (they came back tonight). I'm reaching the 6 connection limit on MySQL.

I'm confused as to why though. In my code I have the following:

app.config["SQLALCHEMY_POOL_RECYCLE"] = 45

But when I connect to the SQL server and run SHOW PROCESSLIST; I see values in the time column over 200.

  • Shouldn't my above settings close connections after 45 seconds?
  • And should I close the connection manually before render_template, even though I'm using sqlalchemy?

Thanks in advance!

It happens for idle connections only.

@fjl what counts as an idle connection? Some of these are coming from after authenticating. The browser is still open, and the user hasn't logged out, but the connection in MySQL is still open.

Should I db.close() at the end of requests?


If you're using Flask-SQLAlchemy with the pool recycle setting set to less than 299, then you shouldn't need to close the database connections explicitly, no. Could you perhaps post an example of the simplest view you have that is using the database and has problems like this? Perhaps there's something else missing from there.

@giles hopefully this isn't too stripped down. There's a POST method on a few things too, but the POST is very similar to this bit:

SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://{username}:{password}@{hostname}/{databasename}".format(
    "accounts": "mysql+mysqlconnector://{username}:{password}@{hostname}/{databasename}".format(

app.config["SQLALCHEMY_POOL_RECYCLE"] = 45

db = SQLAlchemy(app)

@ app.route('/', methods=["GET"])
def index():
    if devMode is False:
        if request.url.startswith('http://'):
            url = request.url.replace('http://', 'https://', 1)
            return redirect(url, code=301)
    if not current_user.is_authenticated:
        return redirect(url_for('login'))
    if request.method == "GET":
        q_results = db.session.query(Table1, Table2, Table3).filter((Table1.value_id ==

        return render_template("file.html", result=q_results)

Thanks again!

Hmm, I can't see anything obviously wrong there. One difference between the way I normally write Flask-SQLAlchemy code and the way you've done it is that I tend to use Model.query functions and you're using db.session.query directly (which makes sense, as you're doing a multi-model lookup). I wonder if you need to commit the session there to close it properly (even though you're not making changes)? Alternatively, perhaps you're not committing the session in the views where you handle the POST (which would need it due to the changes)?

@giles, thanks again for the information. I'm trying to troubleshoot this problem, a bit tricky since it's intermittent. Is there a way to increase DB connections from 6? I don't see an option on the customize plan?

And if not, does that mean if 7 people hit the site within 300 seconds of eachother, that 7th person will get an error?


We could potentially bump it up, but I suspect that that would make the problem worse -- if you're leaking connections, then you'll hit that problem, and having more would just make it harder to track down because it would be more intermittent (but just as serious).

Just a thought -- maybe you could keep a MySQL console up and running, and run "SHOW PROCESSLIST" in it to see where the connections are coming from and what they're doing when the problem happens? That might be a bit tricky, though, as the MySQL console itself might time out. Perhaps worth trying, though?

Hi Giles, I'm not 100% certain that's my issue, it's a bit hard to track down.

Is what I said accurate? 7 people connecting at the same time (within 2 seconds of each other) would cause an issue?

What should I look for? A 500 in the error logs?


We provide 3 database connections per worker so, if you're managing them correctly, you should not need more, no matter how many people are accessing your site, because each worker will only process a single request.

Look in your error and server logs for tracebacks that you can use to work out what the issue is.

حل مشكله ان السرفر يفصل فجأه pythonanywhere

Please describe the issue you're facing and we'll try to help.