The “HOSTS” file in Windows and other desktop operating systems is designed to provide the system with a local version of the “DNS” system.
DNS (Domain Name System) is the global infrastructure behind the way the “web” works. If you type “Google (.) com” in the URL address bar, the DNS network delivers the correct IP address for your computer to access.
While this works fine with the “WAN” (Wide Area Network), when it comes to the “LAN” (Local Area Network), there can sometimes be problems with the file, preventing the system from being able to connect to others.
The solution is to make sure that if you’re looking to develop any kind of local network functionality, you can connect to the right systems. This tutorial explores how to do this.
HOSTS file + local network functionality
If you have a local network, it may be the case that you have added a printer or some other resource, and want to give people easy access through a “domain name”.
Since the Internet’s domain name system isn’t really designed for LAN functionality (although it can point domains to local IP addresses), it deals with the HOSTS file to make sure it has the ability to route domain names to specific IP addresses. .
Unfortunately, it may be the case that this file becomes corrupted or does not have the correct IP addresses stored, causing problems with the LAN.
To ensure that this is not the cause of the problem, and that you can resolve any issues that may be related to it, you need to ensure that your HOSTS file is okay.
You can do this by following the steps described here…
HOSTS file troubleshooting steps
1. Access the file
The first step is to make sure the file is accessible and editable.
To do this, you need to be able to charge it, which can be done by following these steps:
Windows 10 / 8
- Press “Windows” + “S” keys on your keyboard
- Type “Notepad”, right click on the first list and select “Run as administrator”
- When Notepad loads, click “File” > “Open”
- Browse to “c:WindowsSystem32Driversetc”
- Select the “hosts” file to open it
Windows 7/Vista
- Click “Start” > “All Programs” > “Accessories”
- Right click on “Notepad” and select “Run as administrator”
- In the top menu, select “File” > “Open”
- Browse to “c:WindowsSystem32Driversetc”
- Select the “hosts” file and open it
2. Remove any false references
The next step is to make sure the file has all the correct references inside it.
It should typically contain a series of “commented out” lines (starting with #) followed by a list of IP addresses (xxx(.)xxx(.)xxx(.)xxx) and domain names (x (.) com) .
The listings in a “healthy” HOSTS file should simply have the lines commented out; if there are others, you’ll need to make sure they’re listed correctly (they’re probably from some apps on your system).
The only time it would be damaged is if your system ever had a virus (which often dilutes the “HOSTS” file with fake websites).
If you don’t have any domains/IPs listed, it could suggest a lack of connectivity which I’ll explain in the next paragraph.
3. Make sure you add the correct IP addresses
Once inside the HOSTS file, you need to make sure that any of your LAN’s IP addresses are listed correctly.
For example, we had a printer that we accessed through //Printer-1.
Unfortunately, the printer was damaged, which led us to buy another one. This new printer was renamed and became inaccessible to 90% of the network.
The way to fix this was to simply change the printer’s IP address in the HOSTS files on our various networked systems.
Not only did this allow us to redirect the various requests to the new printer, but it also ensured that we were running the HOSTS files correctly within the system.
If you do this, and then close the file after saving it, you will need to reboot for the changes to take effect.