Simple trick to use ports in hosts file

The definition says that a hosts file  maps hostnames to IP addresses. This means you cannot map to specific ports. But sometimes mapping to ports can be useful. So how can this be done?

It is very simple. Lets take an example; I want to map www.technoreply.com to localhost:8080. My hostfile is still untouched, as shown below.

hosts file

Now I would want to include the line “127.0.0.1:8080       www.technoreply.com” to the hosts file. But this does not work.

The solution for this is pretty simple:

What I did was add “127.0.0.1       www.technoreply.com” to the hosts file. Then I accessed my blog using www.technoreply.com:8080. Simple trick, works for me!

You can leave a response, or trackback from your own site.

2 Responses to “Simple trick to use ports in hosts file”

  1. Mani says:

    There is no trick in that… It works even if u invoke with any port, like http://www.technoreply.com:4444

    It only matters the domain name!

  2. Jevin says:

    That is just my point. Once you add the domain name, you can access your localhost via any port. ;-)

Leave a Reply

Powered by WordPress