A localhost is used to establish an IP connection or call to a local computer. It is also referred to as a loopback address. The localhost gives the user the possibility to check the IP stack and is usually used in connection with networks. Here, the IP address is used to communicate with another computer over the Internet. “Localhost” thus refers to the virtual server running on your PC.
What do you use a localhost for?
Test and verify with localhost
The loopback address is used by developers to test web applications and programs. Network administrators also use the localhost to check network connections. For programs that communicate primarily over the Internet, web servers primarily use the local host. If your developed application has Internet access, it is essential to find out if it works as you developed it. This is important for newly designed apps, for example. This way, network connections can be established and network errors can be avoided at the same time.
Block websites with the localhost
If you want to block a malicious website, you can use the hosts file of the localhost. In this file, IP addresses can be assigned to the corresponding domains. This address is used to translate the domain name when you enter a website address in the browser. In most operating systems the host file still exists, but today only the global DNS is used. In your host file there are probably only two entries:
- 127.0.0.1 localhost
- :: 1 localhost
You can find these files in Windows under the following path:
\system32\drivers\etc\hosts
For macOS or other Unix systems, the path can be found as follows:
/ect/hosts
Who or what responds to a ping with the IP address 127.0.0.1?
Your own computer responds to this ping. The most common use for the localhost is to send a ping request. You can use the Windows command prompt to test the connection and detect any performance problems. The Internet Corporation for Assigned Names and Numbers, or ICANN, regulates the assignment of public IP addresses. If you are logged in as an administrator, open the command prompt and follow these steps:
- Open Run function (Windows key + R)
- Type “cdm” and press enter key
- Input: ping 127.0.0.1 or ping loclhost
Then you will see the results on the screen. The number of sent, received and lost data is listed. You can also see the approximate runtime of the data transmission.
What is an IP address?
IP is the short form for Internet Protocol. Every device, no matter if computer, laptop, server, cell phone, etc. that is connected to the Internet, gets a worldwide unique IP address. This is necessary to be able to transfer data packets correctly. This is comparable to telephone numbers or postal addresses. These also ensure that your calls or your mail reach you.
Meanwhile, there are two different versions of IP addresses:
- IPv4: consists of a 32 bit number, which is structured according to a specific pattern. The values range in each case between 0 and 255
- IPv6: consists of 128 bit numbers and was created because the increasing use of the Internet means that version 4 will no longer be sufficient in the long term. With this version, 340 sextillion more IP addresses are available.