If you have ever used a HOSTS file on your Windows computer, you might have seen the LMHOSTS file in the same directory where the HOSTS file is located. The HOSTS file is used to map IP host names to IP addresses. You can also block a website using a HOSTS file. Both the HOSTS file and the LMHOSTS file are different. In this article, we will see what LMHOSTS file is in Windows computers. We will also see if you can disable LMHOSTS Lookup.
What is LMHOSTS file in Windows 11/10?
The LMHOSTS file contains the mappings of IP addresses to computer names (NetBIOS) names. In other words, the LMHOSTS file is used for NetBIOS name resolution. The NetBIOS name resolution resolves a NetBIOS name to one or more IP addresses.
File and Printer Sharing is one of the processes on Windows computers that uses a NetBIOS name. When a Windows computer starts, the File and Printer Service or a similar service (that uses a NetBIOS name) registers a unique NetBIOS name from the name of the computer. The NetBIOS names are resolved either by using the WINS (Windows Internet Name Service) or by using the LMHOSTS file on the local computer.
The WINS (Windows Internet Name Service) is the Microsoft implementation of the NBNS (NetBIOS Name Server), a server that stores the NetBIOS names. Windows computers also store the NetBIOS name cache that includes the resolved NetBIOS names along with their associated IP addresses. The NetBIOS cache is stored in the memory. Initially, Windows checks the NetBIOS name cache to resolve the NetBIOS name resolution before attempting any other method or mechanism.
If the NetBIOS name cache does not contain the NetBIOS name, Windows sends the query or request message to the WINS server. System Administrators have to set up or configure the WINS server manually. If the WINS server is not set up or configured, then Windows uses the LMHOSTS file for NetBIOS name resolution.
In simple words, we can say that the LMHOSTS file is a file used for NetBIOS name resolution when the other methods for NetBIOS name resolution, such as WINS fail.
The LMHOSTS file is located in the same directory where the HOSTS file is located. The complete path to the LMHOSTS file directory is:
You can open the LMHOSTS file in Notepad or any other text editor software. The extension of the LMHOSTS file is .sam. Hence, you need not change this extension to the .txt extension; otherwise, the LMHOSTS file will not work.
How to edit the LMHOSTS file
We have seen what an LMHOSTS file is and what purpose it is used for. Now, let’s see how to edit the LMHOSTS file. If you want to resolve IP addresses to the NetBIOS names, you can edit the LMHOSTS file.
To do so, go to the location where the LMHOSTS file is located. First, create a backup of the LMHOSTS file to restore the original file in case you make a mistake while editing the file. Copy the LMHOSTS file and paste it into another directory on your computer.
Open the LMHOSTS file in Windows Notepad. You will see all the instructions to use the LMHOSTS file to map IP addresses to the NetBIOS names. After reading the instructions, you can enter the IP address in the required format. Now, save the file to the same location. Windows will show you a message to replace the original LMHOSTS file, replace the file.
Go through the following instructions:
- In the Notepad, go to File > Save As.
- Browse to the above-mentioned location (where the LMHOSTS file is located).
- Select All files in the Save as type drop-down.
- In the File name field, type lmhosts.sam.
- Click Save.
- Windows will show you a message to replace the file. Confirm your action by clicking Yes.
How to fix the LMHOSTS file Access denied error
You may see the following error message while saving the LMHOSTS file in the default root directory.
You don’t have permission to save in this location.
Contact the administrator to obtain permission.
It is clear from the above error message that you cannot save the file to the required directory because of permission issues.
You may also see one of the following error messages while accessing the LMHOSTS file:
Access to C:\Windows\System32\drivers\etc\lmhosts was denied
Cannot create the C:\Windows\System32\drivers\etc\lmhosts file.
Make sure that the path and file name are correct.
The above two error messages also occur due to permission issues.
Now, to fix this error message, you need to sign into your Windows computer with an administrator account. After signing into the administrator account, you have to open Notepad as an administrator. The following steps will help you regarding that:
- Click on Windows Search and type Notepad.
- Right-click on Notepad and select Run as administrator. Click Yes in the UAC prompt.
- Go to File > Open or press the Ctrl + O keys.
- Browse to the location where the LMHOSTS file is located.
- Select All files in the drop-down on the bottom right side.
- Select the LMHOSTS file and click Open.
Once you open the LMHOSTS file in Notepad, you can edit it and save it in the required location. Windows will not show you the error message this time.
Should I disable LMHOSTS lookup?
You may have a question, should you disable the LMHOSTS lookup? The LMHOSTS file is used for NetBIOS name resolution. We have explained the different methods that Windows uses for NetBIOS name resolution. If you have configured the WINS server, Windows will use it for the NetBIOS name resolution.
If the WINS server is not configured, then Windows will use another method for NetBIOS name resolution, which is the LMHOSTS file. By default, the LMHOSTS lookup is enabled on all Windows computers. But you can disable it. There are multiple ways by which you can disable the LMHOSTS lookup.
When the other methods to resolve the NetBIOS name fail, then Windows refers to the LMHOSTS file for NetBIOS resolution. If the NetBIOS file is also not configured or disabled, the process of NetBIOS name resolution cannot be completed. Hence, we do not suggest you disable the LMHOSTS lookup. The reason is clear, LMHOSTS lookup will be useful when WINS is not configured or fails.
What is the difference between LMHOSTS and HOSTS file?
Both LMHOSTS and HOSTS files are located in the same directory on a Windows computer. These files are used for different purposes. The LMHOSTS file contains the mappings of IP addresses to computer names (NetBIOS) names. Whereas, on the other hand, the HOSTS file contains the mappings of IP addresses to host names.
What is the LMHOSTS file format?
The LMHOSTS file is a SAM file. You can see its file extension by enabling the File name extensions option in Windows 11/10 or by opening its properties. Select the LMHOSTS file and press the Alt + Enter keys. This will open its properties. Under the General tab, you will see the LMHOSTS file type as the SAM file.
Read next: Hosts File not working in Windows.