Blog

What is: localhost

In computer networking localhost literally means “this computer”. When you type a URL into your browser, you are essentially connecting to a “host” computer somewhere else in the world. This computer serves you the web page that you requested. If you type “localhost” into your browser, however, then your browser will know that you want to connect to the computer you are currently using. If your computer is running web server software like Apache, then your browser will be served a web page by your own computer, which is otherwise known as the localhost. Every computer connected to the internet has an IP address and your localhost has one too. Typically the IP address is 127.0.0.1.

Localhost is often used for testing and development. When a developer installs WAMP, LAMP, or MAMP software stack on their personal computer, then they will typically type “localhost” into their browser in order to pull up their WordPress web site. Local server environments can speed up the development time. It is also great for learning purposes.

Another common usage of localhost is when you are trying to connect to your MySQL database. Usually this happens when you are installing WordPress on your server. It is beyond the scope of this article, but during the WordPress installation you are asked for a hostname which is usually localhost. The reason for this is that WordPress and MySQL both are typically installed on the same server. In order for them to communicate with each other, they must be aware of this. By telling WordPress that your MySQL database server is “localhost” you are basically telling WordPress to look for the database on the same computer.

This post was originally published in the wpbeginner glossary.

Additional Reading