How to change 'localhost' ip address on workstation

Hello Experts

This is a very easy one.

Can someone please show me how to change the ip address of the 'localhost' on my pc.

I believe there is somekind of 'host' or 'winhost' file that I need to change.

At the moment if I ping localhost it comes up with, which we all know is the loopback address. I want to change it to specific ip address.


Who is Participating?
Darr247Connect With a Mentor Commented:
You need to take ownership of the %windir%\system32\drivers\etc\HOSTS file, first.

Then make a shortcut on your desktop with a target of
%windir%\notepad.exe "%windir%\system32\drivers\etc\hosts"
Start in: %windir%
and named HOSTS.

Then you can just open that shortcut when you want to make changes to HOSTS.

However, I don't really think you can change 'localhost' from with HOSTS, as it's hard-coded...  in fact ALL 127.x.x.x addresses are reserved for loopback, so if you ping you will get a reply whether it's in HOSTS or not; if you change the loopback entry in HOSTS to  localhost
flushdns/registerdns and/or reboot, then do
ping -a
it will still not resolve to "localhost"
David Johnson, CD, MVPOwnerCommented:
edit your hosts file and change localhost to point to where you want. (you need admin permissions)
Dave BaldwinFixer of ProblemsCommented:
I recommend against changing localhost to any other IP address.  You don't know how many other applications depend on that.  Instead, find the IP address of your machine and use that.  Here are two methods of finding your IP address:
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Dave BaldwinFixer of ProblemsCommented:
Doesn't it work the other way around, ping -a will resolve names to IPs but not the other way around?  On this machine, 'localhost' resolves to '::1' which is the IPV6 version.
No... DNS resolves names to IPs.

Names are not needed at all to run a ping... when you ping a domain name it gets the IP from DNS and every hop along the path actually uses the IP address, not the name.

If you ping a reachable IP address no domain name is displayed; ping -a essentially does a reverse DNS lookup.
Danny ChildIT ManagerCommented:
what are you actually trying to achieve here, please?
Localhost is *supposed* to be the loopback address:

If you can describe the actual problem, we can widen the scope of the answers.
cpatte7372Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.