What is Local Host? – GeeksforGeeks

When you call an IP address on your computer, you

try to contact another computer on the Internet, but when you call IP address, you are communicating with the localhost. Localhost is always your computer. The computer communicates itself when it calls the localhost. The computer does not always directly identify the local host. Within its network, localhost has a separate IP address such as (for most cases) which is different from the one you use on the Internet. This is usually dynamically assigned by the Internet Service Provider (ISP). Localhost can be viewed as a server that is used on your computer.

This term is generally used in the context of networks. Localhost is not only the name of the virtual server, but also its domain name. Like .example, .test, or .invalid, ., .localhost is a top-level domain reserved for documentation and testing purposes. When accessing the domain, a loopback is triggered. If you access “http://localhost” in the browser, the request will not be forwarded to the Internet through the router. Instead, it will remain in your system. Localhost has the IP address This refers to your server. – How does loopback work? IP addresses are used to communicate with each other within a network. Network participants have their unique addresses. Using TCP/IP data packets can reach the correct destination. The Transmission Control Protocol (TCP) and Internet Protocol (IP) protocol pair are some of the main features of the Internet. TCP/IP is also used outside the Internet on local networks. The Internet Protocol is responsible for allowing the IP address and subnet mask to be directed to subscribers on a network during transmission.

The assignment of public IP addresses is regulated by an international organization which is the Internet Corporation for Assigned Names and Numbers (ICANN). ICANN is also responsible for the assignment of domain names called the Domain Name System (DNS). But certain address ranges are reserved for special purposes, such as the range from to There is no reliable information as to why that range was chosen. IP addresses on the Internet are divided into different classes. The first Class A class started with (reserved address) and ended with 127 is the last block of the Class A network. His important position could have been the reason for his selection.

Within this address range, a local network can be configured. The unique thing about this range is that IP addresses are not uniquely assigned, as is often the case. In addition, it was reserved by ICANN.

If you enter an IP address or the corresponding domain name in your browser, the router forwards your request to the Internet, which connects you to the server. This means that if you enter, you will reach the Google homepage, but the situation is different with Requests to this address will not be forwarded to the Internet. TCP/IP recognizes from the first block (127) that it does not want to access the Internet, but is calling itself. This triggers the loopback.

The reason a loopback device is created is for the backlink to your computer to work. Through the operating system, this virtual interface is created. The interface is called a loopback interface (lo/lo0) and can also be displayed using the ifconfig command on Unix systems. A similar command for Windows is ipconfig.

What is localhost used for? Developers use the local host to test Web applications and programs. Network administrators use loopback to test network connections. Another use for localhost is the host file, where you can use loopback to block malicious websites.

For testing purposes: Web servers primarily use the local host for programming applications that need to communicate over the Internet. During development, it is important to find out if the application works as it was developed once you have access to the Internet. The other functions of local hosts are only possible if the required files can be found on the Internet. As we can see there is a difference between opening an HTML document on your PC or uploading it to a server and accessing it. Launching a product without testing it makes no sense. Therefore, developers use the loopback to test them. They can stimulate a connection and at the same time avoid network errors. The connection simply remains completely within your system.

Another advantage of using localhost for testing purposes is speed. It usually takes more than 100 milliseconds when you send a request over the Internet. The maximum transmission time is only one millisecond to ping localhost. Internet protocol correction can also be implemented using this technology.

If you want to configure your test server on your PC to address it through the localhost, the appropriate software is needed. Software such as XAMPP designed specifically for use as a localhost can be used.

To block websites: Localhost can also block files on the host. This file is a predecessor of the Domain Name System (DNS). In this case, IP addresses can be assigned to the corresponding domains. The domain name is translated into an IP address when you enter a website address into your browser. It used to be the host file, but nowadays the global DNS is usually used, but the host file is still present in most operating systems. On Windows, the file is located in system32driversetchosts, whereas, with macOS and other Unix systems, it is located in /etc/hosts.

These two entries will probably remain if no changes are made to the file

: localhost ::

1 localhost

Name resolution for the localhost does not need to be done over the Internet. Localhost can also use the host file to block certain websites. To do this, the website to be blocked must be entered into the list, and the IP address must be assigned to the domain. If you or a malicious script tries to call the blocked domain, the browser will first check the host’s file and find your entry there. You can also use the domain name

The browser will try to access the corresponding website on the server with However, it is unlikely that the browser will be able to locate it, since the requested file will not be there. However, if your testing server is set up, then the browser can find .html startup, which is just your file. An error message appears instead of the requested Web site if you have not configured the testing server. System-wide ad insertions can be disabled using this technology. To avoid each entry manually, you can find regularly terminated and extended host files on the Internet.

Contact US