Mobile app version of vmapp.org
Login or Join
Dunderdale272

: Will altering my HOSTS file allow me to access sites that can't be directly accessed via IP? I'm moving hosts over to a shared host (HostGator) and trying to access my site before DNS propagation

@Dunderdale272

Posted in: #Dns #IpAddress #Migration #Wordpress

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:WindowsWinSxSamd64_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)?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Dunderdale272

2 Comments

Sorted by latest first Latest Oldest Best

 

@Dunderdale272

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.

10% popularity Vote Up Vote Down


 

@Merenda212

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme