My custom domain works with GitHub Pages but I would like to understand how it actually works.

For this example I am not using my custom domain at all. My GitHub Pages repository does not contain a CNAME file.

E.g. Given a GitHub Pages repository without a CNAME file: example.github.io

DNS request for example.github.io resolves to

running the ping command for example.github.io also returns the same IP address:

When I open the website http://example.github.io in the browser, the browser show the contents of the actual website.

When I type an IP address instead or make an HTTP GET request with a tool like Postman, all I see is a GitHub Pages 404 error.

Why can't I access my GitHub User page by an IP address directly? I thought that browsers replace hostname part of the URL with the IP address response of a DNS lookup, prior to making an HTTP request.

2 Answers 2


Yes, web browsers does a DNS lookup and uses that ip address for the connection. They also take the original host name and send it as part of the Host http header. This allows a web server to serve multiple web sites from the same ip address.



curl --header "Host: jzelenkov.github.io"
  • Thanks for the answer. I was not aware of the Host header. Unfortunately, I still see GitHub's 404 error page, even when Host: jzelenkov.github.io header is present. Does it mean that GitHub Pages require other HTTP headers to be present as well to show the actual contents of the webpage?
    – Jay
    Apr 16, 2014 at 9:35
  • Well, this works for me, and I don't see what other headers could be needed: curl --silent --show-error --header "Host: jzelenkov.github.io" | grep -q "I am Jev Zelenkov" && echo Works
    – andol
    Apr 16, 2014 at 9:40
  • I can verify that it works for me now as well.
    – Jay
    Apr 16, 2014 at 10:44

I think that your site is not the only site that is on that ip, even because if every project on github has a unique ip. On that server probably there are configured hundred of sites of github users.

And probably they are configured using a virtual host structure. In that case the apache server has many entries in the format of:

    <VirtualHost *:80>
    DocumentRoot "/blablabla"
    ServerName example.gihub.io

   <Directory "/blablabla">


The ip that you use is just the ip of the server that hosts your site. So many sites share the same ip.

This is why you cannot access your page directly. And probably they set a 404 error for all requests that doesn't use a valid virtual host. And this is why you are receiving a 404 not found error.

For access directly the page using the ip, refer to andol answer, using curl --header etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .