dark mode light mode Search Menu

What is Localhost?

medithIT on Flickr

Recently while reading the news wire for this magazine, crammed in between amazing headlines titled Sudden Progress on Prime Number Problem Has Mathematicians Buzzing, Own a Street-Legal Flamethrowing Batmobile Replica for Just $200K, and Absurd Creature of the Week: This Parasite Eats a Fish's Tongue "” And Takes Its Place (with a disgusting photo!), I noticed an article titled Quickly Preview Localhost Project with Sublime Text.

At the risk of losing readers, links to the articles about Batmobiles, prime numbers, and disgusting parasites are at the bottom of this article.

The last article, however, got me thinking I should write about localhost. If you own an Apple computer, for example, you might not realize your computer includes a web server, Python, and a few other goodies for programmers and soon-to-be programmers. Localhost is a key gateway to use this stuff.

What is localhost? It’s a name and address, usually used by a web browser to find a web server on your computer. Instead of typing myfavoritewebsite.com you type localhost in the URL bar of your web browser. If your computer has a web server, and is configured properly, you will see a basic web page. On Grendel, my ancient iMac, calling up localhost in my browser displays a message, “It works! And unlock!” No idea the last bit — what unlocked?

Localhost like any self-respecting website address also has a unique IP address: typing in the URL bar of your web browser displays the same results as typing in localhost. What’s an IP address? IP stands for internet protocol which refers to a set of standards (protocols) used to communicate on the internet. Imagine if every computer on the internet spoke a different language. Because computers transfer data with the same standards, data moves quickly and efficiently. Your web pages and email show up as you (hope and) expect.

The difference between localhost and any URL like myfavoritewebsite.com is localhost traffic never travels on a network. Data is transmitted within your computer. People typically use localhost to do web-based software development on their computer then transfer files to a remote web server for test and launch.

Technically, localhost is called a hostname. A hostname is a label assigned to a computer on a network, for example, www.nytimes.com is a label assigned to the computers that host the New York Times website on the internet network. Their website also has an IP address computers actually use to deliver data between their servers and your web browser. But you rarely if ever see the New York Times IP address. You only see the hostname, www.nytimes.com, in your web browser.

Another interesting detail about localhost is that it uses the http protocol. While you can type www.nytimes.com or nytimes.com into the URL bar of any web browser, sometimes the hostname has http:// or https:// added to the front, as in http://www.nytimes.com. The http bit stands for hypertext transfer protocol. Like IP addresses, http is another internet standard used by computers to communicate with each other. However, there are other protocols you can use locally, for example, file:// works in some web browsers to display files on your computer. And ftp:// in some web browsers displays folders and files stored on remote computers after you login to the remote computer.

If you’re a programmer and want to use localhost to display web pages, there are a few ways to make it happen. If your computer does not include a web server, you can use XAMPP to install Apache (web server), MySQL (a database), and the PHP programming language. These are all free open source software technologies. If you have an Apple computer, the Library/Web Server/Documents folder should be the root folder of your web server.

Once you find the folder for your local web server, whether the server is included (Mac OS X) or added (XAMPP or similar), the next steps are to add any additional languages you need then start coding. You can use localhost to view your web pages.

Learn More





Sudden Progress on Prime Number Problem Has Mathematicians Buzzing


Own a Street-Legal Flamethrowing Batmobile Replica for Just $200K


Absurd Creature of the Week: This Parasite Eats a Fish's Tongue "” And Takes Its Place


Quickly Preview Localhost Project with Sublime Text