1. Introduction

Network addresses are used to identify various resources on a network.

In this tutorial, we’ll review the difference between and localhost. First, we’ll define what they are and where and how they are used. Lastly, we’ll depict the difference between the two terms. Let’s start with some definitions.

2. What Is is an IP address that is specifically assigned to the loopback interface, i.e a loopback address. is a non-routable, private IP address used to establish a connection with the same device on which the address was entered. For example, entering the command ping in a command prompt window will connect with the originating device:


Pinging with 32 bytes of data:
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128

Ping statistics for
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

So why do we need to establish a connection with the originating device? In some cases, we would want to validate the Internet Protocol (IP) stack on a device connected to the network. It is used to test connection protocols. In addition, allows us access to the network services running on the originating machine.

Now, this is particularly useful when developing applications, specifically web applications. For example, developers may host an application web server and configure the address as Every time we enter this address, the local web server’s page is loaded.

It is also essential to note that is not the only loopback address present on a device. There is a whole range associated with it. Consequently, any address from to will function in the same way.

3. What Is localhost?

The term localhost is usually used to refer to the local computer with the loopback address As such, typing ‘localhost’ in the browser’s address bar will connect with the device itself. The purpose of localhost is to serve as a domain name for

Therefore, we can say that localhost has the same function as a loopback address.

4. How Do They Work?

Let’s illustrate how they work with the Transmission Control Protocol/Internet Protocol (TCP/IP) model. The TCIP/IP model defines a standard for communication in IP networks. It is composed of four main layers illustrated below:


TCP layer in OSI model

Communication on the sender’s side is from top to bottom and vice versa on the receiver’s end.

A packet addressed to any of these two addresses on the sender’s side will first go through the application and transport layer. Upon reaching the Internet layer, once it is detected that the destination address is or localhost, the packet is sent back to the device. It does not exit the local network.

5. What’s the Difference?

More often than not, localhost and are used interchangeably. The two are considered the same thing. However, there are subtle differences that exist between them. Let’s look at these:

  • Firstly, the IP address associated with localhost has to be resolved or looked up, while does not usually require resolution.
  • Secondly, localhost is not always resolved to It may be resolved to another address within the loopback block of addresses.

6. Conclusions

In this article, we’ve explained and localhost. We’ve described how it works and the purpose it serves. Lastly, we’ve identified application development as the main application of these two terms.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.