1 min read

Troubleshoot Common Nginx Issues on Linux Server

Check if NGINX is running:

systemctl status nginx

If NGINX is not running, you could start it with:

systemctl start nginx

If NGINX did not start after a reboot, you could enable it so that it starts after the next reboot:

systemctl enable nginx

Check your nginx config syntax:

nginx -t

If you get an error, you would need to fix that problem and then you could restart NGINX:

systemctl restart nginx

If you get Syntax OK when running nginx -t then your confiruation is correct, so I would recommend checking your error
logs:

tail -f /var/log/nginx/error.log

Check the permissions of the files and folders in your document root:

Find the user that your nginx service is running as:

ps auxf | grep nginx

If you are using Ubuntu, the user should be www-data, so you would need to make sure that your files and folders are
owned by that user, so nginx could read and write to those files:

chown -R www-data:www-data /var/www/yourdomain.com

Check if nginx is binding to the default ports:

netstat -plant | grep '80\|443'

Check if ufw allows TCP connections on port 80 and 443:

ufw status

Orestis Pantazos

Orestis Pantazos

DevOps Engineer