Locahl
Buy Locahl
WordPresslocal developmenthosts file.testMAMP

WordPress Local Development With a .test Domain (hosts file)

Set up a local WordPress site with a clean .test domain using the hosts file. Works with LocalWP, MAMP, XAMPP and Docker. Map the domain, flush DNS, configure WP.

L

Locahl Team

Β·2 min read

To run a local WordPress site on a clean domain like `mysite.test`, map it to `127.0.0.1` in your hosts file and point your local server at the WordPress folder. This replaces ugly URLs like localhost:8888 with a real, memorable domain that behaves more like production β€” and it works with LocalWP, MAMP, XAMPP, and Docker.

Set up local WordPress with a .test domain

1. Add the domain to your hosts file:

TEXT
127.0.0.1 mysite.test

2. Flush DNS β€” on Mac or on Windows. 3. Create a virtual host in your stack pointing mysite.test to the WordPress directory (MAMP/XAMPP Apache vhost, or a Docker/Nginx server block). 4. Tell WordPress its URL in wp-config.php:

PHP
define('WP_HOME', 'http://mysite.test');
define('WP_SITEURL', 'http://mysite.test');

5. Open http://mysite.test and finish the WordPress install.

Why .test (not .dev or localhost)

.test is reserved by the IETF for testing, so it never collides with a real domain and browsers do not force HTTPS on it (unlike .dev). Pick the right TLD with which TLD to use for local development, and get the line format right with the hosts file syntax guide.

Per-tool notes

Local HTTPS (optional)

If a plugin requires HTTPS locally, generate a trusted certificate with mkcert β€” see local HTTPS on Mac with mkcert β€” and set the URLs to https://mysite.test.

Manage multiple WordPress sites cleanly

Running several WordPress builds means several .test domains, and the hosts file gets cluttered fast. Locahl keeps each project’s mapping with a one-click toggle and flushes DNS automatically, so switching between WordPress sites is instant. For a broader stack view, see hosts file for Laravel and WordPress local dev.

_Last tested: June 2026 with WordPress 6.x on macOS, Windows and Linux._

Also readhosts file for Laravel and WordPress local dev
Also readWhich TLD to use for local development
Share this article
Available on Windows, macOS & Linux

Ready to simplify your workflow?

Stop wasting time with the terminal. Locahl lets you manage your hosts file in a few clicks, with automatic validation and no risk of errors.

  • Intuitive visual interface
  • Automatic DNS flush
  • Multi-environment management
  • Automatic backups
  • JSON Import/Export
Buy Locahl β€” $5.99One-time payment, no subscription

Reader Reviews

4.7β˜…(3 reviews)
Priscilla A.
β˜…β˜…β˜…β˜…β˜…

"Set up mysite.test for my WordPress build in minutes. So much cleaner than localhost:8888."

June 13, 2026

Hassan B.
β˜…β˜…β˜…β˜…β˜…

"The WP_HOME / WP_SITEURL tip made my .test domain work perfectly with MAMP."

June 11, 2026

Greta L.
β˜…β˜…β˜…β˜…β˜…

"Great walkthrough. A multisite subdomain example would round it out."

June 9, 2026

Frequently Asked Questions

How do I use a custom domain for local WordPress development?

Map a .test domain to 127.0.0.1 in the hosts file (e.g. 127.0.0.1 mysite.test), point your local server (MAMP/XAMPP/Docker) at the WordPress folder for that host, and set WP_HOME/WP_SITEURL to http://mysite.test.

What domain should I use for local WordPress?

Use a .test domain. It is reserved for testing and will not clash with real domains or force HTTPS like .dev does.

Why not just use localhost for WordPress?

localhost works but is generic and breaks when you run several projects. A named .test domain per site is clearer and matches the eventual production URL more closely.

Do I need to flush DNS after adding the hosts entry?

Yes, flush DNS so the new mapping takes effect, then load the .test domain in your browser.

Related Articles

11 min read
LaravelWordPresslocal development

Hosts File Setup for Laravel and WordPress

Configure hosts files for Laravel Valet, Herd and WordPress local development with .test domains, multisite setups and best practices.

L

Locahl Team

2 min read
hosts fileWindowseditors

Best Hosts File Editors for Windows (2026)

The best hosts file editors for Windows in 2026: Locahl, Notepad as admin, Hosts File Editor+, SwitchHosts and BlueLife Hosts Editor. Pros, cons and when to use each.

L

Locahl Team

Developer tools team

2 min read
hosts filednsmasqwildcard

Wildcard Local Domains: hosts File Limits & dnsmasq

The hosts file does not support wildcards like *.myapp.test. Learn why, and how to set up wildcard local domains with dnsmasq on macOS and Linux.

L

Locahl Team

Developer tools team

2 min read
WordPressDNSmigration

Test a WordPress Site Before DNS Propagation

Preview and test a WordPress site on a new server before DNS propagation using the hosts file. Map your real domain to the new IP, verify, then switch DNS safely.

L

Locahl Team

Developer tools team