To access your localhost web server at 127.0.0.1 click on this link.
The IP address 127.0.0.1 is reserved for use by the local web server (localhost), which you can access directly from the navigation bar using any of these 4 ways:
What is localhost (127.0.0.1)?
A localhost web server (whose IP address is 127.0.0.1) is the local implementation of your own web server, reachable from your personal computer and contains all the features of a traditional web server, except the access from the outside (or from the local network).
Definition of 127.0.0.1
In the RFC 5735 (Request for Comment) of the Internet Engineering Working Group (IETF), is specified the use of reserved IPv4 addresses for some defined purpose. In particular, an 8-bit loopback address block (for local testing) is defined called 127.0.0.0/8, where the localhost IP address 127.0.0.1 belongs.
This IP address 127.0.0.1 is not a public or private IP address, it can only be accessed only from your personal computer, therefore localhost can help to many web development tasks and testing a web server without security risks from internet.
Localhost 127.0.0.1 structure
It is known that localhost (or 127.0.0.1) is a web server mounted on your personal computer, you have all the features from a full web server inside your computer: A root directory and a home directory, to host all directories of your local projects and websites. You can also access these directories through urls that in the default configuration follow this syntax:
– Access through localhost:
– Access through 127.0.0.1:
Through that request, you should receive a response from the localhost website.
Http port for localhost (127.0.0.1)
A port of any IP address is a connection that is established for a network interface using the TCP/IP protocol. A network interface allows multiple network connections using different ports, however one port cannot be assigned for more than one simultaneous connection.
In the case of localhost (IP address 127.0.0.1), the standard port allocation is also followed. The standard port for the http protocol is the number 80. In port notation a url must follow this syntax:
Following that syntax, an example of url could be this (the same as 127.0.0.1):
In this example, since 80 is the standard port for the http protocol, we can omit the number 80. Therefore following the same notation for localhost, the above url translates as:
With the same access from the website as indicating port 80.
Https port for localhost (127.0.0.1)
The https protocol means: “secure http”, where a layer of security is added to the http protocol, encrypting all the data obtained from the client. To make the encryption, https uses the TLS/SSL method to encrypt the clients data through a SSL certificate, protecting the client data that is transferred over the network.
The default port for the https protocol is 443. Therefore to access localhost through the https protocol could be seen as follows:
However, this notation is not correct, because 443 is not a port available for plain text (like http of port 80), so 443 requires https encrypted information. A correct url using 443 port for localhost
And since 443 is the default port of the https protocol, the url of localhost in https should finally be shown like this:
Note: If the protocol is http, the default port is 80, and if the protocol is https, the default port is 443, but in neither case is it shown in the url.
Easy web server for localhost
If you are trying to access the IP address 127.0.0.1 (http://127.0.0.1) or localhost (http://localhost) from your browser and you have no answer (page not found), it is very likely that you do not have configured a web server into your local computer.
To create your own web server, you must learn how to configure it on your personal computer before launching a web server on 127.0.0.1 that handles any kind of requests from your LAN or internet. Below we will show you a simple way to create a web server using Apache.
Simplest web server setup
If the operating system of your computer is MacOS, Linux or Windows, you can install an Apache web server. The goal is create an Apache web server to process your localhost requests.
For Windows users, there is an integrated web server called IIS, with this web server you can process your requests, however we will focus on the simplest configuration of an Apache web server.
You must download Apache from its official website. We recommend you download the latest version, although you can download the version that suits you best, you should immediately unzip the file.
Install Apache on localhost (127.0.0.1)
Installation in Windows
If you are using Windows, you will have to go the folder created when unzipping the file, it is called apache24. Depending on the version there are two possible ways:
- In some Windows versions, it will be enough to run the .msi installer of Apache.
- You can move the entire apache24 directory to C:\ for simplify the configuration. To do this, through the command line (cmd) you execute the following commands, as follows:
Running httpd.exe loads the default apache configuration located at httpd.conf and initializes the web server. If the installation has been successful, when open localhost the result should be similar to the one shown in this image:
Apache installation on Linux
To install Apache on Linux, you have to install the package according to the environment in superuser mode:
Install Apache in Ubuntu
sudo apt-get install apache2
Install Apache on Fedora
sudo yum install httpd
Then we start the Apache service:
# Start Apache service in Ubuntu sudo systemctl start apache2
# Start the Apache service in Fedora or CentOS sudo systemctl start httpd
To enable the service, we enter the follow command:
# Enable Apache service at boot systemctl enable httpd.service
Finally enter in the browser: localhost (or 127.0.0.1) to verify that the installation has been successful. You should see a message like the following:
If you see this message when open localhost (http://localhost) in your browser, the Apache installation was successful.
Apache installation on MacOS
For MacOS, Apache was installed by default, you just have to enable it from the terminal using the following command:
By the same way as in Linux, you must verify that localhost can be opened in your browser. If there is an answer, the enabling process was successful.
Localhost Web Server Configuration
Once your web server is installed on 127.0.0.1 and localhost have a successful answer, you should customize the default configuration of your httpd.conf file, for example: configure VirtualHosts, change your DocumentRoot (which is the default document directory), Listen for ports, etc.
Apache is a complex web server and have many options to configure, many modules and another features that we will see later. If you want to implement a full web server on localhost (also available at 127.0.0.1), maybe you could consider implementing a LAMP server (Linux – Apache – MySQL – PHP) or WAMP (Windows – Apache – MySQL – PHP).
If you want to build a complete LAMP server, you could check this tutorial, also we recommend the installation of a database manager (MySQL, available from localhost) and PHP (To execute .php files at server code).
It is important to show that the port used for MySQL is different from 80 and 443. We invite you to discover it!