2007-08-08: You followed the steps in my article
how do I host my own website at home. And it
worked— people outside your home can access your website
just fine. But you can't access it by home when you connect to
it by name. You see your router's administrative web pages instead.
What is the problem?

When you connect to your home-hosted website by name, the name
resolves to an IP address. That IP address is the address of your
home router. And your home router is designed to assume that
any connection to the web server port coming from inside
the home is intended for the router's administration pages—
even though you have carefully configured the router to forward
connections on port 80 (the web server port) to your home-based
web server.

Some routers are smarter than others: they can tell the
difference between an attempt to connect to the "outside" address
of the router and an attempt to connect to its "inside"
address (usually 192.168.2.1). But some, alas, are not so smart. And with
these routers, you will not be able to connect to your home-hosted website
by name from within your home.

So how do you work around the problem without buing a better router?
If you just need to test your home web server from one of your PCs,
you can edit the hosts file on that PC so that the
name of your web server automatically resolves to the internal
IP address of your home web server. When your computer needs to
translate a website name to an IP address, it consults the
hosts file first before consulting
DNS servers, so we can use
this technique to avoid involving your router when your home PC connects
directly to your home-hosted website.

On Windows XP, the hosts file is located here:

c:\windows\system32\drivers\etc\hosts

You will need to open this file with Notepad and add
one line at the end. Here I assume that your
home-hosted site is called example.is-a-geek.com
and that the internal IP address of your home-hosted site
is 192.168.2.100, but you must use the correct
name and internal IP address for your site. If you don't
understand this, you should read
how do I host my own website at home?
before continuing.

Here's the line to add to your hosts file:

192.168.2.100 example.is-a-geek.com

"How do I edit the hosts file?" You can use Windows
Notepad. Note that you will not see hosts listed
when you browse to the c:\windows\system32\drivers\etc
folder with Notepad. That's because the filename does not have,
and must not have, a .txt extension. If you
manually type in hosts after browsing to the correct
folder you will be able to edit it.

After making this change, save the file and restart
your computer. You will now be able to access your home-hosted
website from this particular home PC. If you need access from
multiple home PCs, you will need to edit their hosts files as well.

If you are running MacOS X on your home PC, you can still
edit your hosts file. In your case the file is at
the location: /private/etc/hosts

Linux users can find their hosts file at:
/etc/hosts

If every computer, not just computers in your home, sees your
router's administration pages when connecting to your website, then
you have a different problem. You have checked the "allow remote
administration" box in your router's administration pages. This is
dangerous and prevents you from hosting a website at home.
Uncheck the box.

Legal Note: yes, you may use sample HTML, Javascript, PHP and other
code presented above in your own projects. You may not reproduce
large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this
FAQ by adding our
syndicated feed to
your friends list!