In computer networking, “localhost” refers to the computer that a certain program is running on. For example, if you’re running a program on your own computer (like a web browser or local web development environment), then your computer is the “localhost”. On the other hand, if you’re talking about a MySQL database that sits on your host’s web server, then your host’s web server is the “localhost” in that scenario.
In the most simple terms, you can essentially think of localhost as meaning “this computer”. Just remember that “this computer” applies to the program, not necessarily to the computer that you’re physically using.
On a more technical level, localhost typically resolves to the IP address 127.0.0.1, which is known as the loopback address. Because of its importance, the term “localhost” is a reserved domain name. That means that, in order to avoid confusion, it’s impossible to register a domain name that contains “localhost” in the top-level or second-level domain name.
2 Common Situations Where You’ll Encounter Localhost With WordPress
There are two areas where you’re likely to encounter the term localhost in connection with WordPress:
- Developing/testing WordPress websites in a local environment
- Setting up/configuring access to your WordPress site’s database
First, many WordPress developers create something called a “local testing environment” to build WordPress websites. Essentially, this environment mimics a live website but is entirely self-contained on the user’s own computer.
Because the site only exists on the localhost, it’s easy for developers to test things without fear of breaking something on a live website that might be receiving external traffic. Once the site is complete, developers can then move the website from their localhost environment to a live server environment.
Beyond WordPress development and testing, you also might run into the term localhost if you’re manually entering or editing your WordPress site’s database credentials. This could happen both when you’re editing your wp-config.php file or working with a plugin.
Below, you’ll learn a bit more about each situation…
How To Install WordPress Locally (Your “Localhost”)
There are a number of both general and WordPress-specific tools that you can use to create a local WordPress development environment. With any of these tools, you essentially create a self-contained web server on your own computer. Here are some of the most common local development tools for WordPress:
- DesktopServer – a WordPress-specific local development solution. We actually have a detailed guide on how to install WordPress locally with DesktopServer.
- MAMP – a cross-platform local development environment that can use both Apache and NGINX.
- XAMPP – a general local development environment using the Apache web server.
- WampServer – a Windows-specific Apache web development environment.
With all of these tools, you’ll first need to install and configure the tool to create your local environment. Essentially, this is a localhost web server (that is – it’s a web server running on “your computer”). Once your local server environment is running, you can install WordPress on it like you would at your host. Some tools, like DesktopServer, also include built-in mechanisms to quickly install WordPress.
You’ll then be able to access your local WordPress site by typing “localhost” into your browser address bar:
Why Your WordPress Database Is Located At Localhost In Most Situations
As you learned at the beginning of this article, “localhost” simply means the computer that a program is running on.
Here’s why that’s important to your WordPress site’s database:
In 99% of situations, your WordPress site’s database will be located on the same server as the rest of your WordPress site’s files. As a result, whenever you’re editing your wp-config.php file or a plugin asks you for your “MySQL hostname” or “MySQL host”, you can just enter “localhost”.
For example, here’s what the DB_HOST entry in the wp-config.php file looks like for a WordPress installation at Kinsta:
In both these situations, you’re basically telling WordPress (or a WordPress plugin) to look for the database on the same server where WordPress is located. While you’re unlikely to encounter the term localhost on a daily basis unless you’re a developer, it does come in handy to know how localhost relates to WordPress.
Remember – for an easy way to remember what localhost is, just think of phrases like “this computer” or “the computer this program is running on.” It’s that simple!
If you enjoyed this tutorial, then you'll love our support. All Kinsta's hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans