I'm moving hosts over to a shared host (HostGator) and trying to access my site before DNS propagation has completed, so I can access my WP-ADMIN (which can't be done w/ temporary URLs).

I'm told that editing my HOSTS file (w/ the domain name and new IP) will allow me to access it prior to migration. But what's the difference between doing that and just skipping altering HOSTS typing in the IP address directly?

I feel like I'm missing some fundamental beyond "DNS takes a name and translates to an IP address." b/c typing in an IP clearly isn't the exact same as typing a domain. Example - I ping StackOverflow, HostGator, and Google and go to their respective IP addresses I get: "Error 103", "Error 404", and no error at all, respectively.

Ultimately, I just want into my WP-ADMIN before propagation is complete. I've updated HOSTS and my computer seems to bypass looking at it (Windows 10 using FF, Edge, Chrome. One space between domain and IP. Hosts file has no extension. Registry entry for HOSTS points at the system32/drivers/etc folder correctly. I even updated the lesser known HOSTS found in - C:\Windows\WinSxS\amd64_microsoft-windows-w..ucture-other-minwin_31bf3856ad364e35_10.0.10586.0_none_c1c535cf0f692563).

Before I keep endlessly troubleshooting why my HOSTS file is being ignored, I'd like to know if a) that will actually allow me to get into my WP-ADMIN and b) Why (since I'm obviously not understanding something in the DNS fundamentals)?

  • The hosts file can replace the need to resolve a domain name to an IP address via DNS. However, while there are some that swear by them, I do not like using the host file. The reason is simple. It is a pain in the nether regions. One of my friends lives and dies by the host file. I live and die by my own internal DNS server. Both work. However, it has always paid for me to be patient and just let the DNS do what it does. It often does not take very long. For you, it mostly depends upon your at home ISP. Cheers!
    – closetnoc
    Commented May 1, 2016 at 18:05
  • If you are editing the correct HOSTS file and it doesn't appear to be working then it's possible you are seeing the result of a cached DNS entry, in which case you'll need to clear your DNS cache. eg. If on Windows: ipconfig /flushdns from a command prompt. Also, make sure you have the correct "hostname" (not "domain") in your HOSTS file. eg. www.example.com or example.com (or both).
    – MrWhite
    Commented May 1, 2016 at 22:27

2 Answers 2


Yes - altering a HOSTS file locally to redirect a domain to an IP isn't the same as simply typing in that IP into the browser. The reason why is that in shared hosting, one IP address houses multiple domains. When you type in that IP address of "your" site (which is also the IP of other sites as well), the server can either a) Give an error b/c it doesn't know which domain should be associated with that IP or b) Go to one of the sites that has that IP the server picks in some way.

The reason why is that the IP address hits the server, the virtual hosts that are serving multiple sites will also look in your HTTP header request (from your browser) to know which specific hostname to query. Since an IP address lacks this extra bit of info (the hostname), the server will give back an error. Altering the HOSTS file fixes this, since it 'carries' with it that hostname in the header now.

Rather than continue to struggle endlessly with altering my HOSTS file. I found it much easier/faster, and just as effective, to download the Virtual Hosts plug-in for Chrome which edits the HTTP header info upon querying a site. By opening the plug-in and putting in the IP address of the server, and the domain name (the hostname) I'm looking for, the virtual host now knows what to return and works perfectly.

  • The server generally uses the first site created when only the IP address is provided. In smarter configurations, this would be a catch-all site where an error can be generated or some other option given.
    – closetnoc
    Commented May 1, 2016 at 22:52
  • 1
    On Linux, I'd suggest using dnsmasq for greater flexibility.
    – user3919
    Commented May 3, 2016 at 0:18

The short answer is yes.

Adding the domain name and IP to your HOSTS file will resolve the domain, locally, to the IP you have entered. When you then visit that domain in your web browser, along with your request to the web server (at that IP address you entered), your browser will send the domain name you have requested. The shared web server will then use this to display the correct web site to you.

Using your HOSTS file is pretty much just like delegating your domain name - only the changes can only been seen locally.

EDIT: some additional help

If you'd like to post your HOSTS file contents, we might be able to help troubleshoot why that's not working as well. One thing, make sure you've cleared your browser cache in case that is caching the DNS.

Also, if you want to avoid the whole HOSTS file thing entirely, you can use the temporary URLs to get into wp-admin. If you edit your database, in the wp_options table you just need to change the site_url and home_url values to your temporary URL to stop wp-admin from automatically redirecting you.

  • Thx Tim - I had just figured out the answer right before you posted yours. Definitely correct and +1. I put up my answer as well since I discovered a fix for the issue in the process of learning about virtual hosts and HTTP headers. Commented May 1, 2016 at 20:24
  • 1
    Ah glad you solved it @TonyDiNitto! I just edited my answer before I saw your comment to add some additional help as well, but that plugin for Chrome sounds like a pretty nifty way to get around it :)
    – Tim Malone
    Commented May 1, 2016 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.