Forums

WebApp FTutorial - 502 Bad Gateway -- following FLASK tutorial.

"Add a new Web App" --> Select Flask --> All done --> Go to browser --> I see "Hello from flask" .. All good so far.

Then follow along the tutorial and replace the original code with the new code given. Going to website again gives "502 Bad Gateway". There is nothing in the "error.logs". But server logs show this:

============================
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - lock engine: pthread robust mutexes
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - uwsgi socket 0 bound to UNIX address /var/sockets/gagrawal.pythonanywhere.com/socket fd 4
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - Python version: 2.7.4 (default, Apr 19 2013, 18:30:41)  [GCC 4.7.3]
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - *** Python threads support is disabled. You can enable it with --enable-threads ***
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - Python main interpreter initialized at 0x1d001d0
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - your server socket listen backlog is limited to 100 connections
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - your mercy for graceful operations on workers is 60 seconds
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - setting request body buffering size to 65536 bytes
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - mapped 333872 bytes (326 KB) for 1 cores
2013-09-18 12:36:13 +0000 gagrawal.pythonanywhere.com - *** Operational MODE: single process ***
2013-09-18 12:36:14 +0000 gagrawal.pythonanywhere.com - WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x1d001d0 pid: 16865 (default app)
2013-09-18 12:36:14 +0000 gagrawal.pythonanywhere.com - *** uWSGI is running in multiple interpreter mode ***
2013-09-18 12:36:14 +0000 gagrawal.pythonanywhere.com - spawned uWSGI master process (pid: 16865)
2013-09-18 12:36:14 +0000 gagrawal.pythonanywhere.com - spawned uWSGI worker 1 (pid: 16866, cores: 1)
2013-09-18 12:36:15 +0000 gagrawal.pythonanywhere.com - announcing my loyalty to the Emperor...
2013-09-18 12:41:25 +0000 gagrawal.pythonanywhere.com - received message 0 from emperor
2013-09-18 12:41:25 +0000 gagrawal.pythonanywhere.com - SIGINT/SIGQUIT received...killing workers...
2013-09-18 12:41:25 +0000 gagrawal.pythonanywhere.com - lost connection with my emperor !!!
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - limiting number of processes to 32...
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - your processes number limit is 32
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - your memory page size is 4096 bytes
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - detected max file descriptor number: 123456
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - building mime-types dictionary from file /etc/mime.types...2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - 532 entry found
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - lock engine: pthread robust mutexes
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - uwsgi socket 0 bound to UNIX address /var/sockets/gagrawal.pythonanywhere.com/socket fd 4
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - Python version: 2.7.4 (default, Apr 19 2013, 18:30:41)  [GCC 4.7.3]
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - *** Python threads support is disabled. You can enable it with --enable-threads ***
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - Python main interpreter initialized at 0x12c11d0
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - your server socket listen backlog is limited to 100 connections
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - your mercy for graceful operations on workers is 60 seconds
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - setting request body buffering size to 65536 bytes
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - mapped 333872 bytes (326 KB) for 1 cores
2013-09-18 12:41:26 +0000 gagrawal.pythonanywhere.com - *** Operational MODE: single process ***
2013-09-18 12:41:27 +0000 gagrawal.pythonanywhere.com - WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x12c11d0 pid: 16872 (default app)
2013-09-18 12:41:27 +0000 gagrawal.pythonanywhere.com - *** uWSGI is running in multiple interpreter mode ***
2013-09-18 12:41:27 +0000 gagrawal.pythonanywhere.com - spawned uWSGI master process (pid: 16872)
2013-09-18 12:41:27 +0000 gagrawal.pythonanywhere.com - spawned uWSGI worker 1 (pid: 16873, cores: 1)
2013-09-18 12:41:27 +0000 gagrawal.pythonanywhere.com - chdir(): No such file or directory [core/uwsgi.c line 1318]
2013-09-18 12:41:27 +0000 gagrawal.pythonanywhere.com - VACUUM: unix socket /var/sockets/gagrawal.pythonanywhere.com/socket removed.
==========================

Any idea what is going on? Is pythonanywhere buggy? I see some other posts also claiming this same error. Has this error not yet been fixed?

regards. GA

Did you visit your web app before the little "spinner" next to the Reload button had stopped spinning?

We think that there is a bug in PythonAnywhere where sometimes (but irritatingly quite rarely, as otherwise it would be easy to debug) if you hit a web app while it is reloading, it won't start up properly. You can fix the problem by hitting the Reload button again -- I just did that and your app is running OK now.