LookIP logo

What is localhost?



You've probably heard of the term somewhere: localhost, also known as 127.0.0.1 or loopback device. But, what is it? It is, in fact, a very crucial part of networking in general. No worries, it's not difficult to understand, so we will explain it to you.
The term localhost translates to 'the local system', meaning that whenever you point towards it, it will be pointing back to your own device or computer. Localhost is the human-readable name for the unique address of your computer, which translates to 127.0.0.1 through DNS as its IPv4 tcp ip address or ::1 when using IPv6. The loopback device is also known under the following names: localhost address, loopback interface, loopback network interface, loopback ip address and loopback address.

Although most people don't need to know it exists, when setting up a testing-environment which has to be unreachable from the outside world it is very convenient. It is possible to change your server-software to listen to 127.0.0.1 as its main IP address. By definition, it is not possible to reach it from outside your computer as it is only available from the local network, therefor the potential problem of unknowingly publishing your content is mitigated.

Using localhost

Now that you know about the 'localhost' trick, you might be wondering how you can put this knowledge to use.

Network administrators and web developers often utilize the localhost IP address to set up a private testing server. This local server mimics a real internet server but is only accessible from the local machine. It's invaluable for developing web applications, allowing developers to test their work in real-time without affecting live sites. This setup is also known as a virtual server because it operates within the operating system, simulating a separate computer network environment.

First off, you need to install something that we want to be listening to the hostname so that we are able to use it locally. This could be something like a gameserver or webserver with an internet connection. As an example, let's say we want to build a website without some sort of CMS, like WordPress, to see what we are creating. To do that, we first want to start off by installing a webserver like Apache or nginx and set it up to listen to localhost. This does require some technical knowledge, but there are plenty of software packages doing this for you during installation.

Some examples of software packages offering easy localhost installation are:

The best thing about these free installers, is that they receive regular updates, so you can use the current packages of PHP and the MySQL database server. They also offer an array of additional tools, such as an FTP server, but also different programming languages like Perl and Python.
Another cool thing is that you can easily use their add-ons to install 3rd-party packages like WordPress and Joomla, so you can create your website locally and afterwards move it to a external web hosting server.

You may also choose to download and install these CMS packages from their maintainers, which we've listed here:

WordPress https://wordpress.com
Joomla! https://www.joomla.org
Drupal https://www.drupal.org


After you have installed the software of your choice, you only have to start it and decide which services you want to be enabled by default, when restarting your computer. For a webpage to be served from your local computer, only using Apache will be enough. If you also require a database, as is needed when using any of the earlier mentioned CMS-systems, you will also need to enable the MySQL database server.

Accessing localhost

When the web server has been started, you will see a folder structure, just as you would when using a paid web hosting package. It is located at /xampp/htdocs, which is the location to which you can move the files you want to see through your web browser by accessing http://localhost or https://localhost. If you are installing a CMS, you will also have to use this localhost as its base path.

https://localhost
Visiting localhost through your browser


So, let's say that you have placed an index.html or index.php file in the /xampp/htdocs folder, and you type http://localhost or http://127.0.0.1 into your web browser, the contents of the files will be displayed, and if you did it correctly, this will mean that you see the output and not the code itself.

When you've installed software that listens to localhost, you can access it through the following link:

Apache web server http://localhost
WordPress http://localhost/wp-admin
Joomla! http://localhost/administrator
Drupal 6 & 7 http://localhost/?q=user
Drupal 8 http://localhost/user/login

Localhost 8080

Often you also see something like localhost:8080 to access some tool or application. This actually takes the understanding of how localhost works a little further.

When typing in a URL into your web browser, you generally use only the name and TLD. In the case of this website that would be 'lookip' for the name and 'net' as its TLD, separated by a dot. You don't need anything else to access a website. In the background, what your browser is really doing, is adding :80 to the URL, means it wants to access the server by its HTTP port, the port the web server is listening to. For localhost it basically works the same. If you don't add anything to it, you will access the default port for accessing a web server, which is port 80. Now, port 8080 is used to make it possible to run 2 services with the same goal on one computer without them interfering with each other. This is also done when using two web servers with different tasks. The Apache and nginx web servers working in conjunction is a good example of this. Apache takes care of the serving of webpages, while nginx is handling the caching as a reverse proxy.

So, whenever you are suggested to access the application through port 8080. This usually means an alternative route to a web server, to make sure it does not interfere with an existing one. This is also hidden in the number itself, as it is two numbers 80. In equally important fact is that it lies above the restricted range for service ports, which is 1-1023.

You can access the alternative ports by using the following links:

Unsecure access http://localhost:8080
Secure access https://localhost:8080