CentOS Debian Mint openSUSE Red Hat Ubuntu

What is Localhost?

Introduction

Localhost is a combination of two words “local” (your computer) and “host” (server) is a term for a server running on a personal computer.

Localhost allows you to access network services running on that computer using a loopback network port. It is like a web server including Apache, MySQL, PHP, and PHPmyadmin. Below we will tell you what localhost is as we go through it below.

127.0.0.1/loopback address

Localhost is not just a term but it can also be a domain name. It is a network address. If you type “google.com”, it will navigate to Google home. So if you type localhost, it will navigate to your own device. In this case, it will use an IP address let the domain name localhost point to, this special address is called the loopback address.

The default loopback address is 127.0.0.1, located in the loopback IP range of your computer is from 127.0.0.0 to 127.255.255.255. If open address 127.0.0.1 with IPv4 connection, it will enable loopback. You can enable loopback with IPv6 connection by typing :1.

Purpose of Localhost

What can you do with localhost? There are 3 special advantages that loopback/localhost does:

1. Check the internet connection:

You can check the internet connection by using the ping command. Open the terminal and type “ping 127.0.0.1” or “ping localhost” to check:

$ ping 127.0.0.1

Output:

2. Check software or web applications

This is very useful for programmers when they create web applications or software that need an internet connection.

3. Block site

The essence of this is that you change the IP address of a domain name to 127.0.0.1. For example, I want to block the domain “google.com”:

Firstly. we will access to hosts file by text editor:

$ sudo nano /etc/hosts

Secondly, you type:

127.0.0.1 google.com

Save it and the domain “google.com” was being blocked.

Conclusion

You have just seen the details of what localhost is, what 127.0.0.1/loopback is, and their purpose.

Thanks for reading.

Similar Posts