nginx not serving requests to external IP address

Solution 1:

You have server name as

server_name 109.123.x.x;

This is wrong !!!!!

Put any name not number like

server_name mywebsite.home;

and put mywebsite.home as the IP of the nginx server in your host file(/etc/hosts) i.e in your mac like in format

109.123.X.X mywebsite.home

where X.X gets replaced with numbers

or

If you want to serve all the request , simply put

server_name _;

If that does not solve the things , check below

It's either your firewall i.e iptables blocking your traffic or you have your nginx listening only at localhost i.e 127.0.0.1

Disable firewall

sudo ufw disable

Check the listening address for port 81

sudo netstat -tulpn

Solution 2:

I had the same problem a few months ago when I was trying to run ngnix on my Ubuntu system and access the services from another Windows system. I was not able to access any port service like http://127.0.0.1/8000 but after some time, I fixed this by turning off the firewall on my Ubuntu system.

Command to turn off the firewall:

sudo ufw disable

You can also check the status of your firewall first:

sudo ufw status