> host example.com
example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946

I type 93.184.216.34 instead of http://example.com in Chrome. It doesn't load the website. Why?

closed as off-topic by Gerald Schneider, sleske, peterh, 200_success, MadHatter Dec 5 at 5:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – Gerald Schneider, sleske, MadHatter
If this question can be reworded to fit the rules in the help center, please edit the question.

  • As a rule of thumb, humans should never use IP addresses, unless configuring an actual server. – David Richerby Dec 3 at 10:37
  • Worth emphasizing that you did get a response from the server: a 404 HTTP response. This means that it successfully found the host (the computer on the other side) and some web server (I'd guess something open source running on Linux, like Nginx) running on that host sent back data. – jpmc26 Dec 4 at 23:14
up vote 106 down vote accepted

Because the proper HTTP Host header is often required to actually get the intended site.

It's very common to host multiple web sites on the same IP address and distinguish between them based on the HTTP Host header specified by the client (as well as the TLS SNI value nowadays in the case of HTTPS).

That is, when you entered http://example.com into your browser the Host header was example.com, but that is not the case when you entered 93.184.216.34. You reach the same web server in both cases, but you receive different responses (in this particular case 200 vs. 404).

  • 4
    Could someone expand a little on what Host does and what web servers generally use it for? It's kind of hard to search for online because that word is so overloaded. – user1717828 Dec 1 at 20:24
  • 1
    tools.ietf.org/html/rfc7230#section-5.4 A http server processes a Host header however it wants to. httpd for example has VirtualHost configuration directives. – John Mahowald Dec 1 at 20:36
  • 19
    @SergiyKolodyazhnyy Sure. You could curl -H "Host: example.com" http://93.184.216.34/ or something like that. – Håkan Lindqvist Dec 1 at 22:16
  • 13
    To paraphrase - "there is not a one-to-one relationship between URLs for websites and IP address." – Pete Dec 2 at 7:20
  • 1
    In fact that particular server (93.184.216.34 2606:2800:220:1:248:1893:25c8:1946) handles at least example.com example.net example.org example.edu on the same address(es), which is why it really needs the name in the Host header. – dave_thompson_085 Dec 2 at 14:58

Because usually web servers use "virtual server" technology and are able to answer on your HTTP request within exactly the domain name you request, but not the IP address of the web servers. Thanks to hiding more than one domain name on one IP address.

For example, the Apache web server is able to respond to your HTTP request with an IP address using the section:

<VirtualHost *:80>
ServerName Default
...
</VirtualHost>

or if No VirtualHost used in configuration at all.

The VirtualHost feature in Apache was introduced in 1996.

In Apache, you can host many websites using just one single IP address. This is called virtual hosting. It's how subdomains can be created, even standalone domains. This is done by setting up an Apache configuration file containing VirtualHost directives for each domain/subdomain.

An example HTTP server that has two virtual hosts, example1.com and example2.com can look like this (IP address definition):

<VirtualHost 93.184.216.34:80>
  ServerName example1.com
  ServerAlias www.example1.com
  DocumentRoot /var/www/example1.com
</VirtualHost>

<VirtualHost 93.184.216.34:80>
  ServerName example2.com
  ServerAlias www.example2.com
  DocumentRoot /var/www/example2.com
</VirtualHost>

It can also look like this (name-based definition):

<VirtualHost *:80>
  ServerName example1.com
  ServerAlias www.example1.com
  DocumentRoot /var/www/example1.com
</VirtualHost>

<VirtualHost *:80>
  ServerName example2.com
  ServerAlias www.example2.com
  DocumentRoot /var/www/example2.com
</VirtualHost>

In both cases, two virtual host records are created internally in memory and used by Apache to compare against when a URI request arrives.

When a user types in the IP address via a user agent, the first virtual host listed in the configuration file is used as the primary domain (i.e. in this case example1.com).

When a user types in a domain name, the request is sent to a public Internet DNS network (ICANN) which provides the IP address associated with it. You registered both via an ICANN registrar (like GoDaddy). You must have both of these correct and give some time before propagation takes hold to all DNS servers on the ICANN network. These days it can take up to 24 hours.

When the request is routed to your Apache HTTP server, the IP address and domain name are matched against the list of internal VirtualHost records. When one is found, the document root is used to form the full filesystem path to the object resource to return back to the user agent. If not, a HTTP 404 is sent along with any error document associated with it.

I like to use the "house" terminology.

You can quite easily send a letter to a house without a name on it and it'll arrive at the house.

If you put the person's name on it then you're sending to the intended recipient.

The destination is the same but how it is handled when it reaches the house is different.

When you specify the site, i.e. www.example.com then the server knows how to handle the request and which host it is intended for and which site to serve back.

  • This is a helpful metaphor! – Redwolf Programs Dec 4 at 14:35
  • +1 I like the idea of the recipient name. I was thinking of a similar analogy but with IP Address identifying the physical building (computer) but the apartment number (domain name) identifying the actual recipient in multi-tenanted buildings. Of course, this is an over simplification and multi-tenanted computers could have the IP only address server a default site, but I think this is a good analogy. – jmbertucci Dec 5 at 15:49

The key term to search for is "name based virtual hosting".

People want to allocate multiple hostnames to the same web server and serve different content for each hostname. This is known as virtual hosting (not to be confused with the more recent concept of virtual machines).

Initially virtual hosting was done by allocating multiple IP addresses to the server, the sever could then send different content based on the IP address used, but this was seen as wasteful.

Therefore the "host" header was introduced, initially as an extension but then later made a mandatory part of the http 1.1 specification in 1997. This header specifies the hostname the client asked for. The server can then serve up different content based on the value of the header.

  • "but this was seen as wasteful. " Only for legacy v4 connections. Its now quite possible to set up every virtual host on a different v6 address. – Qwertie Dec 4 at 4:01
  • 1
    We are still a long way off from the point where making your public-facing services IPv6 only is a reasonable thing to do. – Peter Green Dec 4 at 6:06

To keep costs down for web servers, a lot of web servers host multiple websites. They do this by using virtual hosts, or Vhosts, in apache2/nginx/etc. So if you go directly to the website's IP Address, you will most likely get an "Apache is working" screen, or possibly even get redirected to the web server's main website.

A Vhost looks at the incoming website address and compares it to the ServerName or ServerAlias names in the enabled Vhosts files. If one of them matches, that specific website is loaded.

Unless the website has a massive load (high numbers of unique visitors/page views) or drives high load applications (think youtube.com, facebook, etc.) it is probably more cost effective to operate on a shared server. It would be a waste of money to get yourself a dedicated server (starting at $60/mo) just to run a Wordpress blog website. You're better off getting a shared platform on a server with probably 200+ websites on one server. Costs will be more in the area of $5/mo.

Another reason for doing this is the lack of IP addresses. There simply isn't enough IPv4 addresses remaining. It is only through the use of NAT for home/business networks and the use of Vhosts that we have any remaining at all. Even when IPv6 becomes main stream, servers will probably stick to Vhosts (server costs).

A dedicated IP address is expensive, while creating a new website on a server is basically free.

What happens is that the hosting company rents a single IP address that points to a physical server, then hosts thousands of websites on that IP address using the "virtual host" feature

Think like a P.O. Box, if you just write down the post office address but without the box number, the mail won't be delivered.

There's a lot of answers here with technical detail, but I think the simplest high-level explanation is that even if a web server is properly listening for http traffic on it's IP address, the server must usually also be configured to answer for a particular domain name, and that name must be in the request sent by the client (i.e the web browser)

I say "usually" because it's almost always done this way, but there are in fact methods where you can setup the http server to answer if only the IP address is used.

We need to understand the differences between Virtual IPs and Dedicated IPs.

If a website has a dedicated (not shared) IP, then (for example) http://123.456.789.012 will bring up the website.

Try this, which is the Dedicated IP address of a site that I own, www.negativeiongenerators.com: http://75.126.128.174 But as others have said, it's usually not a good idea.

  • 1
    This is not universally true. It depends on the web server configuration. You can have a dedicated IP address and still not respond to the IP without the host and you can also have a shared ip address and have the IP address point to one of the websites on the server. There is also nothing wrong with allowing access to a website via its ip address alone although not particularly useful either. – Qwertie Dec 4 at 4:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.