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.

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!

Posted in 




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!
That is just my point. Once you add the domain name, you can access your localhost via any port.