Sleezr
Buy Sleezr
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.

S

Sleezr Team

·3 min read
WordPress Local Development With a .test Domain (hosts file)

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

From local to staging or production

When you later push this local build to a staging server or production, export the WordPress database along with the files. A same-domain move needs nothing more; only if the domain changes do you run a search-replace on the stored URLs, then switch DNS and follow normal propagation. Until then, the hosts file keeps your local .test domain entirely separate from the live site.

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. Sleezr 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._

Sources and further reading

Also readhosts file for Laravel and WordPress local dev
Also readWhich TLD to use for local development
Share this article

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

4 min read
hosts fileadmin rightspermissions

Can You Edit the Hosts File Without Admin Rights?

Can you edit the hosts file without administrator rights? The honest answer plus real alternatives on Windows, Mac and Linux when you cannot elevate (proxy, Docker, local DNS, SSH).

S

Sleezr Team

Developer tools team

4 min read
localhostsubdomainslocal development

How to Use Subdomains on localhost for Local Development

Use subdomains on localhost: the free *.localhost trick browsers resolve automatically, fixed subdomains via the hosts file, and wildcard subdomains with dnsmasq on Mac and Linux.

S

Sleezr Team

Developer tools team

10 min read
hosts fileWindowseditors

Best Hosts File Editors for Windows (2026 Comparison)

Compare the best Windows hosts file editors in 2026: Sleezr, PowerToys Hosts File Editor, HostsMan, SwitchHosts, and Notepad. Feature matrix, pros/cons, and who should switch.

S

Sleezr 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.

S

Sleezr Team

Developer tools team