18 March, 2023

What is localhost? How to set it up with XAMPP and WampServer

Quick summary: Localhost is a term commonly used in computer networking.

Localhost is a term commonly used in computer networking. It is not only the name of a virtual server but also its domain name. Like .example, .test and .invalid, .localhost is a top-level domain reserved for documentation and testing. When you visit it, the request is handled internally with no internet connection needed. That lets you test and develop web applications or network services offline. To understand what localhost is and what it can do, let's MONA explore it in this article.

What is localhost?

In networking, localhost means “the computer,” or more precisely “your computer.” It is a familiar term for people in IT, network administration and programming. Localhost is used to reach network services running on the same machine through a loopback interface, without using any physical network port. This lets the computer act as a virtual network inside itself.

What is localhost

Localhost can be seen as an internal web server made up of components such as Apache, MySQL, PHP, and phpMyAdmin. All of them are installed and run on your computer's hard drive, creating a test environment for development and learning without any online hosting. The advantage of localhost is that you can install and test websites directly on your computer, which makes working with data faster and removes the connection drops that come with web hosting. Because the site is stored on your computer, only you can open and view what is on localhost. No one else can.

What is the IP address 127.0.0.1?

The IP address 127.0.0.1 is a loopback address, a special an IP address reserved for testing and development. It guarantees that any network request sent to this address stays inside the local machine. The loopback range covers all IP addresses from 127.0.0.0 to 127.255.255.255, of which 127.0.0.1 is the most commonly used.

What is the IP address 127.0.0.1

What is the difference between the IP address 127.0.0.1 and localhost?

Although 127.0.0.1 and localhost are often used interchangeably, there are some small differences.

 

127.0.0.1 

Localhost 

The concept of

A specific Class A IP address known as the loopback address. It refers to the computer you are using.

A hostname the operating system maps to the IP address 127.0.0.1. It is used to refer to the local machine in a way that is easier to remember.

Customization

Cannot be customized, because it is a fixed, preassigned IP address.

Can be customized in the system configuration file to map to a different IP address.

Use and access

Used when you need to specify an exact IP address

Used when you want an easy-to-remember way to refer to the local machine

How does localhost work?

When you type localhost into a web browser or connect to a network service on your computer, the operating system recognizes the keyword “localhost” and translates it to the IP address 127.0.0.1 (on IPv4) or ::1 (on IPv6).

How does localhost work?

The operating system does not send the request out through network interfaces such as Wi-Fi or Ethernet. It routes the request inside the system. Your own computer handles it directly, through the software and services running on it.

Services such as web servers (Apache, Nginx), database servers (MySQL, PostgreSQL) or any network application running on your computer listen for requests coming from 127.0.0.1 or localhost. The result is sent back to the browser and shown on your screen.

For example: when you type “http://localhost/index.php” into the browser, it sends a request to the Apache web server running on your computer. Apache finds the file index.php and shows its content in the browser.

One important point: with localhost, data never has to cross any physical network outside the computer. That reduces latency, speeds up processing and keeps things secure, because the data never leaves your machine.

How many types of localhost are there?

As mentioned above, localhost is a webserver, which runs for free on the same computer that holds your WordPress. Inside localhost are many different applications, which are in effect the programming languages used to build websites. Some basic ones in localhost are:

Common types of localhost
  • Apache: One of the most popular languages today, easy to use and with strong features.
  • PHP: A web server program that processes PHP code, the language nearly all WordPress sites use.
  • MYSQL: is database software for storing and processing data. MySQL is very popular, not only in coding but across information and data processing.
  • PHPMyadmin: Software for web administrators to monitor and manage MySQL databases.

Because localhost is used to run and test websites you build offline on your own computer, using the software above makes these tasks much simpler.

Key features of localhost

Here are some key features of localhost:

Key features of localhost
  • Testing programs or web applications: One of the most common uses of localhost is testing programs or web applications. 
  • Blocking websites: Localhost can also be used to block certain websites. If you want users of your computer not to reach a specific site, you can map the site's domain to the localhost IP address in a special file on your computer. When someone tries to open that site on your computer, it is not found there, and the real site on the internet cannot be reached.
  • Speed testing: Localhost can also be used to test your device and TCP/IP protocol under the best conditions. This helps make sure the website or application you build runs stably. For example, you can open Command Prompt or a terminal and type “ ping localhost ” or “ ping 127.0.0.1 ”. The test shows how everything is working, from packets received, sent or lost to how long transmission takes.

Common localhost software for Windows

Localhost needs more than just the programming languages to work. To make it run you also need some software. If you have looked into it, you may have seen names like XAMPP, Wamp and AppServ mentioned often on forums.

In practice these are very important programs: put simply, localhost runs thanks to this software. All three work in much the same way, but XAMPP is used by far the most people.

The reason is that it is the easiest to use, completely free, and runs stably on all operating systems, including Windows, macOS and Linux.

Things to note before installing localhost

To avoid mistakes that can stop localhost from working, keep a few basics in mind: 

Things to note before installing localhost

Remove all related or similar applications to localhost

Some programming applications similar to MySQL or PHP can stop the system from updating localhost.

Also, if your computer already has a web server service like localhost, or IIS installed, installing localhost through XAMPP or Wamp will be disabled. In particular, if you use Skype, switch to another app and uninstall Skype before installing localhost, because Skype uses port 80 and will conflict with localhost during setup and cause errors.

In addition, while IIS can take over port 80, VMware can conflict with a localhost install on port 443. So before installing, make sure none of this software is occupying these ports.

To fix this, remove any similar local software. For port conflicts, move those programs to other ports, or uninstall them and reinstall after localhost is set up.

Turn off the firewall

A web application or antivirus programs are great. But they can block localhost on some ports. Disable them before installing, and turn them back on once installation is finished.

Turn off UAC on Windows

On Windows computers you also need to turn off UAC (User Account Control). It limits the permissions of the localhost installation.

How to install localhost with XAMPP

XAMPP is a popular program for creating a web server on operating systems such as Linux, macOS and Windows. The name XAMPP combines five bundled components: Cross-Platform (X), Apache (A), MariaDB (M), PHP (P) and Perl (P). 

To install localhost with XAMPP, follow these steps:

Step 1: Download XAMPP, choosing the version that matches your operating system, 32-bit or 64-bit.

Download XAMPP

When the download finishes, run the file to start the XAMPP installer. If antivirus software is on, you may see a notice like the one shown. Just choose Yes to continue the installation.

If your antivirus is on, just choose Yes

Step 2: Open the file you downloaded. On the setup screen, click Next to continue installing. 

On the setup screen, click Next

Step 3: On the XAMPP screen, enable the components you want to install, such as Apache, MySQL, FileZilla, PHPMyAdmin… by ticking the box next to each and choosing Next.

On the XAMPP screen, enable the components you want to install

Step 4: On the XAMPP install screen, keep the suggested install path C:xampp. Then choose Next to continue the installation.

keep the suggested XAMPP install path C:xampp

In the next step, pick your preferred language, then choose Next to run the installation.

pick your preferred language, then choose Next

Installation may take a few minutes, then choose Finish to finish the installation.
choose Finish to complete the installation

Step 5: When setup finishes, start the modules from the XAMPP control panel to check your server.

To set up XAMPP you need to run 2 modules: Apache and MySQL

To set up XAMPP you need to run 2 modules: Apache and MySQL

When they start successfully, both modules turn green, as shown below.

When they start successfully, both modules turn green
Step 6: Open a browser such as Chrome or Firefox and enter the IP address http://localhost or http://127.0.0.1. If the page displays normally, localhost is installed. 

Open a browser such as Chrome or Firefox and enter the IP address http://localhost

How to install localhost with Wampserver

Wampserver stands for Windows – Apache – MySQL – PHP. Like XAMPP, Wampserver is another program for creating localhost on Windows.

Step 1: Download the 32-bit or 64-bit Wampserver that fits your machine, unzip it and start the program. 

Download Wampserver

Next, choose Next

Next, choose Next

Step 2: At License Agreement, tick I accept the agreement and choose Next

tick I accept the agreement and choose Next

Step 3: In the next step, choose where to install Wampserver. Then choose Next.

choose where to install Wampserver

Step 4: On the Select Additional Tasks screen, tick Create a Quick Launch icon and Create a Desktop icon then select Next

tick Create a Quick Launch icon and Create a Desktop icon, then choose Next

Then click Install

Then choose Install

Step 5: Choose the default web browser to open Localhost. Here we will choose Firefox. Then choose Open.

Choose the default web browser to open localhost

On this screen you set up PHP mail. If you don't use it, leave the defaults and choose Next.

On this screen you set up PHP mail. If you don't use it, leave the defaults and choose Next.

After the step above, choose Finish to finish installing localhost on Wampserver.

After the step above, choose Finish

Step 6: Restart WAMP and turn this feature on so URLs can run; otherwise the system will only run the main home page.

In the WAMP control panel, choose Apache > Alias Directories > http://localhost/phpmyadmin/ > Edit alias

In the WAMP control panel, choose Apache > Alias Directories > http://localhost/phpmyadmin/ > Edit alias

Then click Ctrl + S and close the file

Now open a web browser and enter http://localhost. If you see the default Wampserver page, the installation worked.

open a web browser and enter http://localhost

Installing localhost on AppServ

Install localhost with AppServ is another way to set up a server environment on your computer. AppServ lets you quickly set up server and a database simply. Although better optimized for Linux/Unix, AppServ still runs stably on Windows.

To install localhost with AppServ, follow these steps:

Step 1: Download the right version of AppServ for your computer. Open the downloaded file, unzip it and start AppServ.

Download the right version of AppServ

Choose where to install AppServ

Choose where to install AppServ

Step 2: Set the configuration values, such as the server name (Server name), the administrator's email address (Administrator’s Email address), and the Apache HTTP port (80 by default).

Set the configuration values

Step 3: Set a username (root by default) and a password for MySQL as you like.

Set a username

Step 4: Click “Install” to start the installation, and choose “Finish” when it finishes.

Install and finish:

Step 5: Open a browser and go to localhost/phpmyadmin to confirm the installation worked.

check that the browser loads successfully

How do I find my localhost?

  • Web browser: Open your web browser and enter http://localhost or http://127.0.0.1 in the address bar. Follow the prompts and you can reach any local application or web server running on your computer.
  • Command line or terminal: You can use the command ping localhost or ping 127.0.0.1 to see whether it is working.
  • Network configuration: A server or program running on your computer usually tells you how to reach it through localhost, including the ports and paths needed.

So should you use localhost?

Whether to use localhost depends on your needs and circumstances. Localhost uses your computer's hard drive as storage and as the place to install a website, which is convenient for learning and testing before you decide to buy hosting.

So should you use localhost?

Moving from localhost to hosting is also quick and simple. But if you want to save costs and keep things secure, consider a reputable hosting provider for a safer solution.

Questions related to “What is localhost?”

Can localhost work without an internet connection?

You can set up a local server without any internet connection. Localhost does not need any external network connection to work.

What are localhost:8080 and localhost:8888?

localhost:8080 and localhost:8888 are two common loopback addresses. Port 8080 is used to run web applications such as PHP or Java, while port 8888 is often used for Java applications.

For example, if you install the Apache web server on your computer, you can open your website by entering localhost:8080 in the browser. Likewise, if you install a Java application on your computer, you can reach it by entering localhost:8888.

What are localhost/htdocs and localhost/wordpress?

localhost/htdocs and localhost/wordpress are paths to two different folders on your computer. The localhost/htdocs folder holds general web files, while localhost/wordpress holds the files for a WordPress website.

That is an overview of localhost and how to install it with XAMPP and Wampserver on Windows. We hope the article gave readers useful information.

Frequently asked questions about localhost

What is localhost?
Localhost is a term commonly used in computer networking.
About The MONA Group: Founded in 2016, with more than 200 staff, MONA has delivered 14,000+ projects with an 85% client retention rate. MONA provides website design, full-scope SEO, custom software and AI automation solutions for businesses. Consulting hotline: 1900 636 648. Explore MONA SEO services and AI tools at work.
MONA has a podcast: listen instead of readingEpisodes on AI, automation & SEO for Vietnamese businesses
Nghe ngay
About the author

CEO & Founder · The MONA

Founder of The MONA, who built a services company of 200+ staff with 14,000+ projects delivered. Khánh Hùng shares how he thinks about building systems that run themselves, automating a business, and the real lessons from delivering projects at MONA.

Views 1,6K
Rate this article 4,9/5 · 16 ratings

Professional website
design services

Own a website with a beautiful, 100% exclusive design and a lifetime warranty, with the ability
to expand features flexibly as your business grows, starting today!

Contact Mona

    MONA có riêng một Người "Bạn Thân" cho bạn - Người Account sẽ đồng hành, hỗ trợ, hướng dẫn, đặt đồ ăn cho bạn mãi mãi, từ đây về sau!
    MONA will never sell your information or send you spam
    Đội MONA tư vấn hệ thống quản lý giáo dục trực tuyến
    Hỏi đáp giáo dục 4.0
    Tạo cuộc hẹn miễn phí với MONA để giải đáp và tư vấn mọi thắc mắc về giải pháp số hoá ngành giáo dục
    Thời lượng cuộc hẹn
    45 Phút
    Ngày và giờ
    Thứ 2, ngày 25 tháng 12, 2023
    [9:30 - 10:15]

      Chọn ngày và giờ
      Khung giờ
      Back
      Hãy cho MONA biết bạn là ai
      0:00