Forums

Error code: 502-backend/ 502 Bad Gateway

I took all the measures like placing app.run() in if __name__ == "__main__" and checked the error logs, modifying wsgi.py file and looked, tried other answers in Help section. Couldn't resolve the issue at all.

ERROR in error.log is as follows

***2022-04-17 13:54:19   File "/usr/lib/python3.8/logging/__init__.py", line 950, in handle
2022-04-17 13:54:19     self.emit(record)
2022-04-17 13:54:19   File "/usr/lib/python3.8/logging/__init__.py", line 1084, in emit
2022-04-17 13:54:19     stream.write(msg + self.terminator)
2022-04-17 13:54:19   File "/bin/user_wsgi_wrapper.py", line 170, in write
2022-04-17 13:54:19     self.logger.error(line)
2022-04-17 13:54:19   File "/usr/lib/python3.8/logging/__init__.py", line 1463, in error
2022-04-17 13:54:19     self._log(ERROR, msg, args, **kwargs)
2022-04-17 13:54:19   File "/usr/lib/python3.8/logging/__init__.py", line 1577, in _log
2022-04-17 13:54:19     self.handle(record)
2022-04-17 13:54:19   File "/usr/lib/python3.8/logging/__init__.py", line 1587, in handle
2022-04-17 13:54:19     self.callHandlers(record)
2022-04-17 13:54:19   File "/usr/lib/python3.8/logging/__init__.py", line 1649, in callHandlers
2022-04-17 13:54:19     hdlr.handle(record)
2022-04-17 13:54:19   File "/usr/lib/python3.8/logging/__init__.py", line 950, in handle
2022-04-17 13:54:19     self.emit(record)
2022-04-17 13:54:19   File "/bin/user_wsgi_wrapper.py", line 113, in emit
2022-04-17 13:54:19     format_with_millis(datetime.now()), self.format(record)
2022-04-17 13:54:19   File "/bin/user_wsgi_wrapper.py", line 99, in format_with_millis
2022-04-17 13:54:19     return "{:%Y-%m-%d %H:%M:%S},{:03d}".format(
2022-04-17 13:54:19 RecursionError: maximum recursion depth exceeded while calling a Python object***

I think problem is on server side wsgi configurations..

Please Needed urgent help from pythonanywhere community

[edit by admin: formatting]

Are you printing a very long line in your code, or perhaps using the Python logging module to log one? If so, that might be the problem. If a line is too long, and your code somehow doesn't follow our normally logging system, then the underlying logger may generate an error saying that the line is too long, which it then tries to log, triggering another similar error, which it then tries to log, and so on.

Try to make sure that your logging and prints inside your code don't log anything more than 1KiB in length.