How to solve "internal server error"

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

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
February 14, 2018
Accepted 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).

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel