Technology Explained

What Is 127.0 0.1, Localhost, or a Loopback Address?

Simon Batt 28-07-2020

There are a few IP addresses that are useful to know off by hand—your router’s IP, for example. One of the lesser-known IP addresses you should know is 127.0.0.1, but what does it connect to and when should you use it?

Advertisement

Let’s explore what 127.0.0.1 is, and what it can do.

What Is 127.0.0.1?

127.0.0.1 is known as a loopback address, but you may see it under the name “localhost.” When you point your browser to 127.0.0.1, it tries to connect to the computer you’re using right now. This is handy when you want to connect to a server on your own computer.

127.0.0.1 is special among IP addresses. Typically, an IP address is unique to every computer on both your local network and the internet. 127.0.0.1, however, always points to the computer you’re currently using no matter what.

For example, if you set up a server on Computer A, you can connect to it by visiting 127.0.0.1 on Computer A. However, if you move to Computer B and type in 127.0.0.1, you’ll connect to Computer B instead of A. You’ll need either Computer A’s internet or local network IP address to connect to it from Computer B.

What’s the Difference Between 127.0.0.1 and Localhost?

There is no real difference between 127.0.0.1 and localhost. Some programs may like one over the other, but they both point to the same location: your computer.

Advertisement

You can imagine localhost as the “name” for the 127.0.0.1 address, much like how “www.google.com” is the “name” for Google’s IP address. However, when you visit www.google.com, it has to go through a DNS server What Is a DNS Server and Why Is It Unavailable? A DNS server matches a host and domain name with its server IP address. When a DNS server is unavailable, you can't reach the URL. Read More so your computer can figure out which IP address matches with the name.

Localhost doesn’t need a DNS server, because your computer already knows that it means you want to connect to it. As such, you can use localhost even if you don’t have an internet connection.

How to Access 127.0.0.1

If you want to connect to your own computer, you can do so like any other IP address. Open up your web browser and type 127.0.0.1 into the address bar, then press Enter. If you can’t remember numbers very well, you can type localhost instead.

If you type this in without any prior setup, you won’t find anything exciting. It’s likely that your browser will tell you that your computer refused your request.

Advertisement

This sounds a little odd, as your computer basically denied itself from connecting to itself; however, it only did so because it’s not expecting any connections at this time. As such, it has no reason to let itself connect to itself, as weird as that sounds!

What Is 127.0.0.1 Used For?

So we have this useful way of telling our PC to connect to itself, but why would we bother in the first place? What practical applications does this have?

Using Localhost to Set Up Networking Tools

While 127.0.0.1 doesn’t do much by itself, things change when you run a server on your computer. When you do, your computer now has a reason to listen to incoming connections, so it won’t refuse your request.

In fact, it will allow you to access a server hosted on your PC as if you were looking at it via the internet. This is valuable when you’re working with networking software and want to ensure everything runs smoothly before putting it on the internet.

Advertisement

For example, let’s say you’re setting up a server that you want others to connect to in the future. Regardless of if you’re using premade software or you’re coding the server yourself, you may want to give it a “test run” to ensure it works before letting others connect.

To do this, you can run the server on your computer, then connect to it using 127.0.0.1. The server will load in your browser as if you had connected to it via the internet while also barring anyone else from peeking in on your work-in-progress.

You can see this in action in our guide on how to set up your own WAMP server. In the guide, we talk about how to set up and run a WAMP server on your computer. Once it’s running, you can then use “localhost” to see your server in your browser without putting it on the internet.

Using Localhost to Play Games With Friends

You can also use localhost when you’re playing multiplayer games. For example, some games allow you to host a server on your PC so friends can play with you. Of course, you want to play along, so you need to connect to the server hosted on your own PC—good thing you have the perfect tool for the job!

Advertisement

Minecraft is one good example where you might use localhost. You can run the server software on your computer to host a world on your PC, but you still need to connect to it via the Minecraft server browser.

To do this, open the server browser and enter “localhost” or “127.0.0.1” as the IP address. Minecraft will recognize this and connect to the server running on your PC.

What’s the Difference Between 0.0.0.0 and 127.0.0.1?

Sometimes you’ll come across another IP address called 0.0.0.0, which seems to do the same job as 127.0.0.1. However, when you compare them, you’ll find that they perform two completely different tasks.

127.0.0.1 is a signal to your computer’s TCP/IP that you don’t want to connect to the internet; you want to connect to a server on your own computer. As such, you’ll typically enter it when telling the software to connect to a server either via a web browser or a game.

0.0.0.0, on the other hand, is more of a wildcard than a specific location. When you use 0.0.0.0, you’re telling the software to allow connections from every local IP address possible, instead of just 127.0.0.1.

Getting to Know Your IP Addresses

There are a handful of useful IP addresses that are handy to know, 127.0.0.1 being one of them. Now you know what it does, how it works, and when you can use it.

If you want to learn more useful addresses, how about finding out your router’s IP address How to Find Your Router's IP Address? What is your router's IP address and how can you access its settings? How can you find a router IP using the device in your hand? Read More ?

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. dragonmouth
    July 28, 2020 at 1:08 pm

    127.0.0.1 is also used to block access to sketchy sites and addresses, such as 'doubleclick'

    • Michael
      July 28, 2020 at 7:44 pm

      Could you elaborate a bit?