Forums

502 backend error on admin page

I just switched databases from sqlite3 to MySQL provided by Pythonanywhere. After running the necessary commands, I noticed all pages on the website worked except the admin page. The admin page displays:

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.

Debugging tips 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

There's nothing unusual in the error log or the access log. The server log shows:

!!! uWSGI process 5 got Segmentation Fault !!!
2020-03-10 20:42:01 *** backtrace of 5 ***#012lordsarcastic www.bonychicken.com uWSGI worker 
2(uwsgi_backtrace+0x2c) [0x46529c]#012lordsarcastic www.bonychicken.com uWSGI worker 
2(uwsgi_segfault+0x21) [0x465661]#012/lib/x86_64-linux-gnu/libc.so.6(+0x354b0) 
[0x7f5cc64714b0]#012/usr/lib/libpython3.7m.so.1.0(+0xe7bbf) 
[0x7f5cc2f58bbf]#012/usr/lib/libpython3.7m.so.1.0(+0x13c441) 
[0x7f5cc2fad441]#012/usr/lib/libpython3.7m.so.1.0(+0xf8283) 
[0x7f5cc2f69283]#012/usr/lib/libpython3.7m.so.1.0(_PyObject_FastCallKeywords+0x104) 
[0x7f5cc2f0b024]#012/usr/lib/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x32aa) 
[0x7f5cc2eddd2a]#012/usr/lib/libpython3.7m.so.1.0(+0x688c0) 
[0x7f5cc2ed98c0]#012/usr/lib/libpython3.7m.so.1.0(_PyEval_EvalFrameDefault+0x7060) 
[0x7f5cc2ee1ae0]#012/usr/lib/libpython3.7m.so.1.0(+0x688c0) 
[0x7f5cc2ed98c0]#012/usr/lib/libpython3.7m.so.1.0(_PyFunction_FastCallDict+0x2be) 
[0x7f5cc2f0a8ae]#012/usr/lib/libpython3.7m.so.1.0(_PyObject_Call_Prepend+0xcd) 
[0x7f5cc2f0ba2d]#012/usr/lib/libpython3.7m.so.1
2020-03-10 20:42:02 DAMN ! worker 2 (pid: 5) died :( trying respawn ...
2020-03-10 20:42:02 Respawned uWSGI worker 2 (new pid: 10)
2020-03-10 20:42:02 spawned 2 offload threads for uWSGI worker 2

My database settings are:

DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.mysql',
         'NAME': '<my username>$<my database name>',
         'USER': '<my username>',
         'PASSWORD': '<my database password>',
         'HOST': '<my username>.mysql.pythonanywhere-services.com',
         'PORT': '3306',
         'TEST' : {
             'NAME': '<my username>$test_<my database name>',
         }
     }
 }

Plus locally, my database is refusing to connect with this error: django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '<my username>.mysql.pythonanywhere-services.com' (110)") What did I do wrong?

PS: '<my username>' is replaced with my actual username.

I've fixed the damned error. I had to delete my virtualenvironment, downgrade to my initial python version: 3.6 (forgot to add that in the question) and recreate it again.

The present problem now is: I can't work on my code on my PC because it gives the error:

django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'lordsarcastic.mysql.pythonanywhere-services.com' (110)")

We do not expose user databases to the internet. See http://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere/