---
title: Edit the hosts file to open a new host (Windows, Mac)
url: https://wp2wp.link/guides/edit-hosts-file
language: en
updated: 2026-11-23
publisher: wp2wp.link
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language questions, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://wp2wp.link/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://wp2wp.link/agents"
---

# Edit the hosts file to open your new hosting

Add one line to your computer’s hosts file: your new hosting’s IP address, then your domain. Then only your computer opens the new hosting, until you remove the line again.

By [wp2wp.link](https://wp2wp.link/guides/about) · Updated 23 November 2026 · 4 min read

- Result: Your domain opens the new hosting
- Your time: About 5 minutes
- Cost: Free
- Your visitors: Still see the old site

## Which way fits you?

- Windows 10 and 11: With Notepad, started as administrator.
- Mac: In Terminal, with your Mac password.
- Linux: In a terminal, with sudo.

## Before you start

- A computer. Phones need extra apps for this.
- Administrator rights on it, or your Mac password.
- Your new hosting’s IP address and your domain.

Check first: this way opens your domain with `http://`. For some domains, browsers refuse that. The wp2wp.link guide checks your domain and only suggests this way when it works. Otherwise use your new host’s [temporary address](https://wp2wp.link/guides/preview-website-before-dns-change), or ask its support for one.

## Your line for the hosts file

The line is the IP address, a space, your domain, a space, and your domain with www:

`203.0.113.10 your-domain.com www.your-domain.com`

The IP address is your hosting’s number, four groups of digits. You find it in your new host’s control panel:

- **cPanel:** in the **General Information** box on the right, as Shared IP Address or Dedicated IP Address.
- **Plesk:** Websites & Domains, your domain’s hosting settings.
- **SiteGround:** Site Tools, Dashboard, **IP and Name Servers**.
- **Other hosts:** look for “server IP”, “shared IP” or “IP address” in the hosting overview or the welcome email. Or ask support.

## Windows 10 and 11

You edit the file in Notepad. Notepad needs administrator rights for this.

1. In the Start menu, type **Notepad**.
2. Right-click Notepad and choose **Run as administrator**.Windows asks for permission: click **Yes**.
3. Choose **File → Open**, paste this path as the file name and click **Open**.`C:\Windows\System32\drivers\etc\hosts`
4. Add your line at the very end, on its own line, and choose **File → Save**.
5. In the Start menu, type **cmd** and open **Command Prompt**.
6. Enter `ipconfig /flushdns`.This makes Windows forget the old address.

## Mac

You edit the file in Terminal with the nano editor.

1. Open **Terminal** in Applications → Utilities.
2. Type `sudo nano /etc/hosts` and press Enter.Enter your Mac password. Nothing appears while you type; that’s normal.
3. Move to the end with the arrow keys and add your line.
4. Press Control+O and Enter to save.Then press Control+X to close the editor.
5. Enter `sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder`.This makes the Mac forget the old address.

## Linux

You edit the file in a terminal with the nano editor.

1. In a terminal, run `sudo nano /etc/hosts`.
2. Add your line at the end.
3. Save with Control+O and close with Control+X.
4. Run `resolvectl flush-caches`.This works on most current systems.

## Open your domain

Warning in the browser: your browser may say the connection isn’t secure. That’s expected here, so continue to the site. If the warning offers no way to continue, remove the line and use a temporary address instead.

1. Close your browser completely and start it again.Browsers keep their own memory of addresses.
2. Type your address with `http://` at the start.For example `http://your-domain.com/reprint-web.php`.

## Undo it afterwards

Once your domain points to the new hosting, remove your line. Then your computer finds your site the normal way again.

1. Open the hosts file the same way as before.
2. Delete your line and save the file.
3. Clear the cache again with the same command.

## How you know it worked

- Your domain with `http://` shows the new hosting, for example the helper’s login.
- Everyone else still sees the old site until you switch the domain.

## If something goes wrong

### I still see the old site

Check the line for typos and make sure you saved the file. Then restart the browser.

### It still shows the old site, and I use a VPN

A VPN can skip the hosts file. Turn it off while you work.

### Windows says I don’t have permission to save

Notepad wasn’t started as administrator. Close it, right-click Notepad, choose Run as administrator, and open the file again.

## Questions

### Does this change anything for my visitors?

No. The hosts file only affects the computer it’s on. Everyone else keeps seeing the old site until you switch the domain.

### Does it work on my phone?

Not without extra apps. Use a computer for this.

### Why does the browser warn about the certificate when I check my copied site?

That’s expected before the switch. Your new host can only create the free SSL certificate once your domain points to it. Continue to the site. The warning only affects your computer.

wp2wp.link walks you through the whole move and tells you whether this way works for your domain.

[Start your move](https://wp2wp.link/#migrate)Free · No account

### Sources, checked 20 November 2026

[Microsoft: ipconfig](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ipconfig), [Apple: reset the DNS cache](https://support.apple.com/en-ca/101481), [resolvectl](https://www.freedesktop.org/software/systemd/man/latest/resolvectl.html), [cPanel interface](https://docs.cpanel.net/cpanel/the-cpanel-interface/the-cpanel-interface/), [SiteGround: hosts file](https://eu.siteground.com/kb/hosts-file), [GoDaddy: preview your website](https://www.godaddy.com/help/preview-your-website-3950), [Chromium HSTS preload list](https://source.chromium.org/chromium/chromium/src/+/main:net/http/transport_security_state_static.json).

## Related guides

- [Open your new hosting before the domain points to it](https://wp2wp.link/guides/preview-website-before-dns-change)
- [Migrate a WordPress site to a new host](https://wp2wp.link/guides/migrate-wordpress-to-new-host)
- [Fix old URLs after a migration](https://wp2wp.link/guides/fix-localhost-urls-after-migration)
