headerImage2

Using your "/etc/hosts" file


Why can't I access my home-hosted website from my own computer? This is a common problem. You have a DNS name for your site, say it is https://www.mysite.com but when you enter this name in your browser on your local network you get your router's administration window. What's up?

Well many (most) home routers and DSL modems direct your outside IP address to your router as a fail-safe measure. This way you will always be able to get to your router's administration page. So how do you access your home based web server from your home browser? First you can always use http://127.0.0.1 or localhost. But why does localhost work?

If you look at your /etc/hosts file (you are running Linux arn't you? If not you deserver all the pain) you will probably see:

127.0.0.1 localhost

Now if your add the line:

127.0.0.1 www.mysite.com

you can now access your website using your DNS name from your local browser. You can also have absolute links in your webpages like:

<a href="https://www.mysite.com/mypage.html">Link to mypage</a>

and the link will get to your web server and not to your router's administration page.