Python Forum

Full Version: 502 Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Our company internal portal is running Python 3+Nginx+flask+Gunicorn on Ubuntu server. This portal was written by previous staff and I have just joined this company. My boss told me that this portal was no problem half a year ago, but now when we load it, the browser shows 502 Bad Gateway and asks me to fix it.

I am a newbie to Python. I already searched on Google, and it seems that Gunicorn, Nginx are still running after reboot. And when searching Nginx error log, it shows

Error:
782#782: *8823 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.10, server: portal.mydomain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://0.0.0.0:5123 /favicon.ico", host: "192.168.1.105", referrer: "https://192.168.1.105/" [
port 5123 is from Gunicorn, I have the following questions:
- I tried to locate favicon.ico in linux but could not find it.
- I tried to search for source files, but also could not find it, I just wondered where it came from?
- As there is no one to touch the system, why has it become this 502 issue in half a year later?

Can any expert share tips with me to solve this? Many thanks!
Finally, I found it seems to be gunicorn issue, when I try restart process manually, it got below exception, any advise on this? Many thank! Undecided

Error:
[2022-10-12 12:25:52 +0100] [3774] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 436, in import_app app = app(*args, **kwargs) File "/home/project/project/__init__.py", line 35, in create_app from main import main as main_blueprint File "/home/project/project/main.py", line 13, in <module> import mail as m File "/home/project/project/mail.py", line 88, in <module> creds.refresh(Request()) File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/credentials.py", line 302, in refresh ) = reauth.refresh_grant( File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/reauth.py", line 347, in refresh_grant _client._handle_error_response(response_data) File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/_client.py", line 60, in _handle_error_response raise exceptions.RefreshError(error_details, response_data) google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'}) [2022-10-12 12:25:52 +0100] [3774] [INFO] Worker exiting (pid: 3774) [2022-10-12 12:25:52 +0100] [3777] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 436, in import_app app = app(*args, **kwargs) File "/home/project/project/__init__.py", line 35, in create_app from main import main as main_blueprint File "/home/project/project/main.py", line 13, in <module> import mail as m File "/home/project/project/mail.py", line 88, in <module> creds.refresh(Request()) File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/credentials.py", line 302, in refresh ) = reauth.refresh_grant( File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/reauth.py", line 347, in refresh_grant _client._handle_error_response(response_data) File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/_client.py", line 60, in _handle_error_response raise exceptions.RefreshError(error_details, response_data) google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'}) [2022-10-12 12:25:52 +0100] [3777] [INFO] Worker exiting (pid: 3777) [2022-10-12 12:25:52 +0100] [3775] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 436, in import_app app = app(*args, **kwargs) File "/home/project/project/__init__.py", line 35, in create_app from main import main as main_blueprint File "/home/project/project/main.py", line 13, in <module> import mail as m File "/home/project/project/mail.py", line 88, in <module> creds.refresh(Request()) File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/credentials.py", line 302, in refresh ) = reauth.refresh_grant( File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/reauth.py", line 347, in refresh_grant _client._handle_error_response(response_data) File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/_client.py", line 60, in _handle_error_response raise exceptions.RefreshError(error_details, response_data) google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'}) [2022-10-12 12:25:52 +0100] [3775] [INFO] Worker exiting (pid: 3775) [2022-10-12 12:25:52 +0100] [3776] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 436, in import_app app = app(*args, **kwargs) File "/home/project/project/__init__.py", line 35, in create_app from main import main as main_blueprint File "/home/project/project/main.py", line 13, in <module> import mail as m File "/home/project/project/mail.py", line 88, in <module> creds.refresh(Request()) File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/credentials.py", line 302, in refresh ) = reauth.refresh_grant( File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/reauth.py", line 347, in refresh_grant _client._handle_error_response(response_data) File "/home/project/.local/lib/python3.8/site-packages/google/oauth2/_client.py", line 60, in _handle_error_response raise exceptions.RefreshError(error_details, response_data) google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'}) [2022-10-12 12:25:52 +0100] [3776] [INFO] Worker exiting (pid: 3776) [2022-10-12 12:25:52 +0100] [3772] [INFO] Shutting down: Master [2022-10-12 12:25:52 +0100] [3772] [INFO] Reason: Worker failed to boot.