Nginx is a very popular web server these days. This article will show you some common errors when running an Nginx web server and possible solutions. This is not a complete list. If you still can’t fix the error after trying the advised solutions, please check your Nginx server logs under /var/log/nginx/
directory and search on Google to debug the problem.
Unable to connect/Refused to Connect
If you see the following error when trying to access your website:
Firefox can’t establish a connection to the server at www.example.com
or
www.example.com refused to connect
It could be that
- Nginx isn’t running. You can check Nginx status with
sudo systemctl status nginx
. Start Nginx withsudo systemctl start nginx
. If Nginx fails to start, runsudo nginx -t
to find if there is anything wrong with your configuration file. And check the journal (sudo jounalctl -eu nginx
) to find out why it fails to start. - Firewall blocking ports 80 and 443. If you use the UFW firewall on Debian/Ubuntu, run
sudo ufw allow 80,443/tcp
to open TCP ports 80 and 443. If you use Firewalld on RHEL/CentOS/Rocky Linux/AlmaLinux, runsudo firewall-cmd --permanent --add-service={http,https}
, thensudo systemctl reload firewalld
to open TCP ports 80 and 443.
Read full tutorial here: https://www.linuxbabe.com/linux-server/how-to-fix-common-nginx-errors