nginx not serving requests to external IP address

220

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
Share:
220

Related videos on Youtube

mike braa
Author by

mike braa

Updated on September 18, 2022

Comments

  • mike braa
    mike braa almost 2 years

    I'm using bootstrap grid. And col-sm-1 is too small but col-sm-2 is too big. I would like to have exact middle one, col-sm-1.5. But when I do it, the whole bootstrap grid collapses. Is there a way to do such grid system?

    • Salman A
      Salman A over 8 years
      I think you could use col-sm-2 and add a child element with width = 75%?
    • mike braa
      mike braa over 8 years
      @SalmanA then I have to change everything for other parts as well, i like the way col-sm8 and col-sm-2 is right now
  • Eamorr
    Eamorr over 12 years
    I switched to port 8080 and it's working now. Might be something to do with a priviliged port or maybe my 3G connection blocks port 81. Anyway, it's working now. Many thanks for your help.
  • radtek
    radtek over 9 years
    If its an instance in the cloud like rackspace or AWS, check your Security Groups. By default port 22 and 80 are the only ones usually open.
  • mike braa
    mike braa over 8 years
    if I extent it then the best part of bootstrap dissapears; "works in mobile"
  • hookenz
    hookenz almost 8 years
    Server name should never really be an IP.
  • GG_Python
    GG_Python almost 8 years
    the sudo ufw disable did it for me.
  • Gabriel Glenn
    Gabriel Glenn over 5 years
    According to the nginx doc, using ip address has server_name is not wrong. "If someone makes a request using an IP address instead of a server name, the “Host” request header field will contain the IP address and the request can be handled using the IP address as the server name":
  • Benjamin
    Benjamin almost 4 years
    The firewall was the problem for me too. In my case (on Fedora 32) I used systemctl stop firewalld to check it.