I’m running a Django application on a Ubuntu server with Nginx and Uwsgi. The application has runned for years and since a couple of days I get a 502 bad gateway error on every request.
Nginx and uwsgi are both active but the nginx/error.log keeps showing : [error] 1269#1269: *72356 upstream prematurely closed connection while reading response header from upstream, client: 50.170.179.62, server: _,
In the first case the server wasn’t rebooted and I got a 502 error 20% off the time, I tried a reboot to solve this problem and after that I’m always getting the 502 error on every request.
There are no software or configuration changes for the last 8 months.
uwsgi logs: I can only find this file uwsgi-uwsgi.log which is empty.
The syslogs gives the following: but I don’t know if this is a possible cause of a badgateway:
Aug 22 14:39:14 clms uwsgi:
Aug 22 14:39:14 clms uwsgi: raise InvalidKeyError()
Aug 22 14:39:14 clms uwsgi: pushbullet.errors
Aug 22 14:39:14 clms uwsgi: .
Aug 22 14:39:14 clms uwsgi: InvalidKeyError
Aug 22 14:39:14 clms uwsgi:
Yeah I know, this is the old server of the customer wich is running for a couple of years.
I’m developing the new one which is up and running but this one is still used.
So I’am the one to solve this problem all well.
However I tried to solve this error to receive new API key and commented some code of pushbullet as well and added a try catch but I keep getting this error.
Do you know anything about this?
This is the file where pushbullet is used
import django
django.setup()
from django.core import exceptions
from pushbullet import Pushbullet, InvalidKeyError
api_key = 'MyKey'
#pb = Pushbullet(api_key)
try:
pb = Pushbullet(api_key)
pb.refresh()
except InvalidKeyError:
# Log the error or notify admins
print("Invalid Pushbullet API key. Please check your configuration.")
# You might want to raise an exception or handle it differently
def push_message(title, body):
# pb.push_note(title, body)
return
def push_to_channel(title, body):
# Get all channels created by the current user
# my_channel = pb.channels[0]
# my_channel.push_note(title, body)
return