How to solve "internal server error"

July 19, 2017 1.2k views

The server connection is showing an Internal Server Error when I access the IPv4. Running sudo tail -30 /var/log/nginx/error.log gives me:

[error] 17876#0: *14 connect() to unix:/var/www/html/site-available/socket.sock failed (111: Connection refused) while connecting to upstream, client:, server: localhost, request: "GET /favicon.ico HTTP/1.1",upstream: "uwsgi://unix:/var/www/html/site-available/socket.sock:", host: "xx.xx.xx.xx", referrer: "http://xx.xx.xx.xx/"

Here is the nginx default.conf

server {
listen 80;
real_ip_header X-Forwarded-For;
server_name localhost;

location / {
    include uwsgi_params;
    uwsgi_pass unix:/var/www/html/site-available/socket.sock;
    uwsgi_modifier1 30;

error_page 404 /404.html;
location = /404.html {
    root /usr/share/nginx/html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;


This is the uwsgi.ini file

#application's base folder
base = /var/www/html/site-available

#python module to import
app =
module = %(app)
home = %(base)/venv
pythonpath = %(base)

#socket file's location
socket = /var/www/html/site-available/socket.sock

#permissions for the socket file
chmod-socket = 777

#add more processes
processes = 8

#add more threads
threads = 8

#kill worker if timeout > 15 seconds
harakiri = 15

#the variable that holds a flask application inside the module imported at
line #6
callable = app

#location of log files
logto = /var/www/html/site-available/log/%n.log

Any suggestions as to how I could resolve the internal server error would be amazing. Thanks

1 Answer

failed (111: Connection refused) while connecting to upstream

This error means that the upstream server (uwsgi in this case) could not be reached. Usually it means that either uwsgi crashed or wasn't even started in the first place. Make sure that it is running and that the socket paths are correct (which they are, in the configuration files that you provided).

Have another answer? Share your knowledge.