Should a website be directly accessible by its IP address?

Note that the website that is reached through a domain name might not be hosted directly at the root of the IP address, i.e. example.org could map to 123.45.67.89/~example. This is common for normal web hosts since they can't allocate an IP address per website – that would be incredibly wasteful.

For instance, if you do a DNS lookup of webmasters.stackexchange.com, you'll get the IP address 198.252.206.140 (on the right-hand side on the website I linked to). While the IP address does go to a StackExchange page, it doesn't lead to the webmasters section, which might be at something like 198.252.206.140/www/webmasters.

One con of using an IP address (or something like 123.45.67.89/~example) is the need for a static IP address. If, for some reason, the IP address should have to change, you have no way of redirecting users. Whereas with a domain name, it's simply a matter of updating DNS records to point to the new IP address.

While not completely related, another obvious con of IP addresses is that they're a lot harder to remember than a name and an ending.

By default, a website will be available through the domain name, as well as by IP address. Different answers/comments to this question offer different perspectives, and I don't want to copy off of that.

Personally, I wouldn't block access by IP address, simply because that's not how one would expect the internet to work. Additionally, a regular user will never randomly find the IP address of your website, and he definitely won't start sharing links to your site with the IP address. So any efforts for SEO and security are surely better spent elsewhere.


The original version of HTTP did not include any mechanism for the client to specify the host name as part of the request. It connected to the server and sent only the path portion of the URL. One of the early modifications to the HTTP protocol was to add the ability for the client to send other "header" information, including the host name.

20 years ago browser support for virtual hosts was very spotty. Back then, there would have been a valid reason to serve the content from just the IP address as well. A small percentage of clients would not have sent the host header. The host name is now a standard header sent by every browser and web crawler.

In fact, I find that requests looking for content on an IP address are not likely to be satisfied if my server responds with my website. I tend to see IP only requests that are:

  • For a website that used to be on that IP address
  • Attempts for access by malware

I now prefer to serve a 404 error for just IP address requests rather than serving my site or redirecting to my site. My servers are also configured to serve 404 pages to unrecognized host names as explained in the answer to How to deal with malicious domain redirections?


Especially if you have a shared hosting or a server of your own hosting multiple domains you can't access the "website" via IP. For your own server you could possibly define a primary domain that is reached if you enter the IP. For shared hosts that is impossible.

As mentioned by @Ijacqu the IP could easily change.

Another thing is duplicate content, so basically it's no good practice to do so.

If you want to have a website to be reached via it's server IP you should definately add a 301 or 302 forward to the domain itself.

For one server I administered I added a small HTML site, just echoing "Welcome to 123.456.789.123" as a default website, as several customer projects were hosted on that machine, and I just needed a white label solution for the default site. I configured that using apache vhosts.

Tags:

Ip Address