Home >Backend Development >PHP Tutorial >Nginx 502 error (django+nginx, not php-fmp)

Nginx 502 error (django+nginx, not php-fmp)

不言
不言Original
2018-04-18 15:17:052027browse

This article mainly introduces the Nginx 502 error (django nginx, not php-fmp). Now I share it with you and give it a reference. Let’s take a look together

Many explanations for Nginx errors on the Internet are that the relevant modules are not running, so first use the ps command to check whether the module is turned on. For example, the most common use is php-fmp in php nginx. module, if it is closed, run the command:

service php-fpm restart && service nginx restart


But I am using django nginx, which has nothing to do with php, so I need to check the nginx error log.

The log location of nginx is in the nginx configuration file. The default configuration file location is: /etc/nginx/nginx.conf, so run:

vim /etc/nginx/nginx.conf

in the curly braces of http Found in:

access_log /var/log/nginx/access.log;

error_log /var/log/nginx/error.log ;

It indicates the log location of normal connection/var/log/nginx/access.log The log file location of abnormal connection /var/log/nginx/error.log

Locate the log file location of the abnormal connection, just:

vim /var/log/nginx/error.log

You can see:

2018/04/17 13:05:39 [error] 9680#9680: *1 connect() failed (111: Connection refused) while connecting to upstream, client: XXXX, server: XXXX, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8000", host : "XXXX"

This is connected to uwsgi, so uwsgi needs to be turned on first, run:

##uwsgi -i uwsgi.ini &

Here uwsgi.ini is my own uwsgi configuration file. I need to run the command according to your actual situation. You can refer to http://uwsgi-docs-cn.readthedocs.io/zh_CN/ latest/WSGIquickstart.html Choose your own uwsgi command.

Then you can use nginx normally and no 502 error will be displayed.


The above is the detailed content of Nginx 502 error (django+nginx, not php-fmp). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn