Troubleshooting

80% of my time while building this project was dedicated to troubleshooting. So you should try to get used to it. Reading and understanding command line warnings and error messages can be really frustrating at the beginning. Even reading through Stack Overflow and other nice computer science forums can be a bit overwhelming if you are a complete beginner. But don't panic. Take your time and patiently work your way through the problem. I hope this page will be of some help to you.

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

1. First, we can check if something is using port 80.

Login as the root user.

sudo su

You can always lift the user privilegies later by typing:

exit

Now, let's check which programs are listening on port 80.

sudo lsof -i :80

If there are any, kill them.

sudo fuser -k 80/tcp

Note: there are a bunch of other methods to check which ports are open and what programs are using them. Visit this page for details.

My personal favourite is:

sudo netstat -tulpn | grep LIST

If your port is busy with the apache server as in my case, you can disable it by typing:

sudo /etc/init.d/apache2 stop

2. There might be a conflict since [::]:80 is a ipv6 address.

>We can make nginx listen to only one of the ports by changing the config file as shown: listen [::]:80 ipv6only=on default_server;

This site cannot be reached problem

1. First, check whether it is a server or a browser issue using this website. If it is a browser problem, follow this guide to debug it.

2. If it is a server issue, however, try following this guide here. Generally you will have at least one of the problems mentioned there.

3. If you are still experiencing malfunctioning, check the firewall status.

sudo ufw status

For a more detailed check:

sudo ufw status verbose

You can try disabling your firewall with disable command. Remember to later enable it back again with enable command.

sudo ufw enable/disable

4. Check if nginx config file has any problems in it.

sudo nginx -t