7

So it seems I can't browse a website by IP, but I can browse using it's hostname.

C:\Users\c>nslookup www.example.com
Non-authoritative answer:
Name:    cx-cdn-bre.gss.consultix.net
Addresses:  62.168.203.241
          62.168.202.241

Trying to access 62.168.203.241 is displaying an "nginx Internal Server Error" But if I access www.example.com, the page loads. How is this possible?

catalin
  • 335

3 Answers3

9

There are a variety of reasons this might be the case. Here are just a couple:

  • host headers - In short, the webserver might host multiple websites on a single IP address. Without the domain name, it cannot display the proper website.

  • load balancing or similar device - the IP address might not be for a website, but to a load balancer, which distributes network load to other devices.

  • name resolution - the name resolution to IP had been changed. For example, let's say the website's address has changed and you manually entered it into your HOSTS file to go to the proper IP.

Keltari
  • 75,447
7

Apache and nginx both (not sure about others....) can serve multiple sites from the same IP based on the host name that is used to connect and request the file(s).

But when you access the server via the IP address, there must be a virtual host defined to service the name used (the IP). The fact that the server is generating an error indicates that there is something "wrong" on the server's config - either it isn't set up to respond to the IP at all, or if it is responding and serving up a PHP or other script that script has issues of some type.

ivanivan
  • 3,042
-3

Because the ip could point to the server but the hostname is merely pointing to a domain which could be a subdomain which could have some other ip all together.

A domain has 132.21.12.21 as ip (example, is made up number). A subdomain (meaning it has the same principal hostname and then something added to it) could have altogether a different ip and to be therefore in a different server.

Also domains can also make it so you can only enter into them through their designed places for security reasons, for example.

You need to think about it as minecraft buildings made of different blocks.

Edited to add a thought to the questioner: You know there is content which is volatile and in differnt parts right? For example, peer to peer, bittorrent etc. There are even botnets using peer to peer being nowhere and everywhere at the same time, and websites which shows content through peer to peer too. I can only hint the answer you want.