nginx flask aws 502 Bad Gateway

2024/11/18 3:28:04

My server is running great yesterday but now it returned a 502 error, how could this happen?

In my access.log shows:

[24/Aug/2016:07:40:29 +0000] "GET /ad/image/414 HTTP/1.1" 502 583 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"

In my error.log shows:

2016/08/24 07:38:50 [error] 14465#0: *12513 connect() failed (111: Connection refused) while connecting to upstream, client: 123.49.616.74, server: app.example.com.au, request: "GET /ad/image/414 HTTP/1.1", upstream: "http://127.0.0.1:8000/ad/image/414", host: "app.example.com.au"

This is the result when I run grep:

ubuntu    6856  0.0  0.6  56624 12652 ?        S    00:08   0:03 /home/www/carbuzzz_admin/env/bin/python /home/www/carbuzzz_admin/env/bin/gunicorn application:application -b localhost:4215
ubuntu    6865  0.0  1.8 180832 36892 ?        S    00:08   0:00 /home/www/carbuzzz_admin/env/bin/python /home/www/carbuzzz_admin/env/bin/gunicorn application:application -b localhost:4215
ubuntu   14300  0.0  0.0  10464   948 pts/0    S+   08:06   0:00 grep --color=auto -i gunicorn
Answer

The HTTP status code 502 normally means that the application server Nginx is proxying to is not running. As this is a Flask app I presume this is something like Gunicorn or uwsgi. Check to see if that is running.

I normally use something like Supervisor to ensure that the application server gets restarted automatically if it goes down.

https://en.xdnf.cn/q/118722.html

Related Q&A

Let discord bot interact with other bots

I have a Python script for a Discord bot and I want it to send a message to another Bot and select the prompt option and then type in a message but I cant get the interaction done. It just sends the me…

Image has 3 channels but its in a grayscale color. If I change it to 1 channel, it goes into RGB

I started doing some image-processing in python and Ive stumbled upon an issue which is kind of confusing from a beginners perspective. I have a dataset of 1131 np arrays (images) of MRI on knee. The s…

Creating a Barplot using pyqt

I need plotting an animated bar chart with pyqtgraph. With animate i mean a chart, which updates his values given by a serial port. For now, a not-animated plot will be enough. I would like to implemen…

Stop Button in Tkinter

Im trying to have a turtle animation start with a button and stop with a button. Its very easy to start with a button but I cant seem to be able to figure out a stop button? Heres my code so far: imp…

binascii.Error: Incorrect padding How to decode the end with /

I received a string encoded with base64, I am using python to decode it, but decoding failed, I found that the string is followed by / ends, I dont know how to decode it, I havent found the answer, who…

How to match words in a list with user input in python?

I am working on program which takes user input and replaces the words in a list with x. eg is the word is sucks and user input is "this word is sucks". the output should be "this word i…

How to plot a ROC curve using dataframe converted from CSV file

I was trying to plot a ROC curve by using the documentation provided by sklearn. My data is in a CSV file, and it looks like this.It has two classes Goodand Badscreenshot of my CSV fileAnd my code look…

SyntaxError: Non-ASCII character. Python

Could somebody tell me which character is a non-ASCII character in the following:Columns(str) – comma-seperated list of values. Works only if format is tab or xls. For UnitprotKB, some possible column…

A pseudocode algorithm for integer addition based on binary operation

I have tried for ages to come up with a solution but just cant get my head around it.It needs to be based on two integers on the use of standard logical operations which have direct hardware implementa…

How to efficiently split overlapping ranges?

I am looking for an efficient method to split overlapping ranges, I have read many similar questions but none of them solves my problem. The problem is simple, given a list of triplets, the first two e…