---
name: azion-test-an-application-through-the-hosts-file
description: >-
  Map your domain to an Azion IP address in your device's hosts file to open an application on that domain before you change its DNS records.
---

# Test an application through the hosts file

You can open an [application](/en/documentation/platform/applications/) on your own domain from one device before you [change the DNS records of the domain](/en/documentation/guides/platform/migration/point-domain-to-azion/). The `hosts` file of that device sends the domain to Azion, while every other visitor still reaches your current provider. To run an application on your own machine instead, use the [Azion CLI](/en/documentation/devtools/cli/).

---

## Prerequisites

- An application that a workload serves. To create one and serve it, refer to [Applications quickstart](/en/documentation/platform/applications/quickstart/).
- Your domain, [added to the domains of that workload](/en/documentation/guides/platform/migration/configure-a-domain/). For more information, refer to [Workloads](/en/documentation/platform/workloads/).
- Administrator rights on your device. Linux and macOS grant them through `sudo`.
- A terminal, such as Windows PowerShell or Terminal on macOS.
- On Windows, a text editor, such as Notepad.
- An internet connection.

---

## Look up the IP addresses of your workload domain

Your workload domain is the `azionedge.net` address that Azion assigns to the workload. It resolves to Azion IP addresses that depend on where the device is. Run the lookup on the device you test from.

Run a DNS lookup tool, such as `host`, with your workload domain in place of `<your-workload-domain>`:

```bash
host <your-workload-domain>
```

The command prints a `has address` line for each IP address that the workload domain resolves to. Copy one of these addresses.

---

## Map your domain to the IP address

The `hosts` file maps names to IP addresses on one device. Add one line for each domain you want to test: the IP address you copied, one or more spaces, then the domain. Map only a domain that you added to the workload.

For example, these lines send `example.com` and `www.example.com` to the address `192.0.2.10`:

```text
# Azion test
192.0.2.10    example.com
192.0.2.10    www.example.com
```

The file ignores the text after a `#` on a line. A comment such as `# Azion test` marks the lines you add, so you can find them when you finish.

The location of the file and the editor depend on the operating system of your device.

### Edit the hosts file on Windows

On Windows, the `hosts` file is in `C:\Windows\System32\drivers\etc\`. When Windows is installed on another drive, the same folder is on that drive.

To edit the file on Windows:

1. **Open Notepad as an administrator**

   Open Notepad, or another text editor, with your administrator rights.

2. **Open the hosts file**

   Open `hosts` from the `etc` folder.

3. **Add your lines**

   Add your lines after the `localhost` line.

4. **Save the file**

   Select **File** > **Save**.

The `hosts` file holds your lines, and Windows resolves each domain in them to the IP address you entered.

### Edit the hosts file on Linux

On Linux, the file is `/etc/hosts`. To edit it with the `vim` editor:

1. **Open a terminal**

   In most distributions, the terminal is in **Applications** > **Utilities** > **Terminal**.

2. **Open the file in vim**

   Run this command:

   ```bash
   sudo vim /etc/hosts
   ```

3. **Enter your password**

   Enter your system password and press **Enter**. The file opens in `vim`.

4. **Add your lines**

   With the arrow keys, move to the line after `localhost`. Press `i` to start typing, then add your lines.

5. **Leave insert mode**

   Press **Esc**.

6. **Save and close the file**

   Type `:x` and press **Enter**.

`vim` saves `/etc/hosts` and closes, and Linux resolves each domain in your lines to the IP address you entered.

### Edit the hosts file on macOS

On macOS, the file is `/private/etc/hosts`. To edit it with the `nano` editor:

1. **Open Terminal**

   In **Launchpad**, search for **Terminal** and open it.

2. **Open the file in nano**

   Run this command:

   ```bash
   sudo nano /private/etc/hosts
   ```

3. **Enter your password**

   Enter your system password and press **Enter**. The file opens in `nano`.

4. **Add your lines**

   With the arrow keys, move to the line after `localhost`, then add your lines.

5. **Save the file**

   Press **Ctrl+O**, then press **Enter** to keep the file name.

6. **Close nano**

   Press **Ctrl+X**.

`nano` saves `/private/etc/hosts` and closes, and macOS resolves each domain in your lines to the IP address you entered.

---

## Open the application on your domain

With the `hosts` file saved, requests from your device to the mapped domains go to Azion. This holds even while the public DNS records of the domain still point to your current provider.

A browser can keep a DNS cache of its own. If it already visited your domain, it can reuse the public address it cached and skip the `hosts` file. To open the domain without that cache, use one of these:

- A private or incognito window.
- A browser that you did not use to visit the domain.
- Your usual browser, after you clear its cache.

Then enter your domain in the address bar. The browser shows the application that your workload serves.

Test the application before you change the public DNS of the domain. Then point its DNS records to Azion, or [move its nameservers](/en/documentation/guides/platform/migration/migrate-ns-to-azion/) to [Edge DNS](/en/documentation/platform/edge-dns/). When you finish, delete the lines you added, so the device resolves the domain through public DNS again.

---

## Next steps

- [Workloads](/en/documentation/platform/workloads.md): Add your domain to a workload, and map the DNS records of the domain to the workload domain.
- [Edge DNS](/en/documentation/platform/edge-dns.md): Host the DNS zone of your domain on the authoritative DNS of Azion.
- [Check the cache status of a response](/en/documentation/guides/application-performance/cache-and-purge/check-page-cache-time.md): Read whether Azion served a response from cache while you test on your domain.
- [Troubleshoot Applications](/en/documentation/platform/applications/troubleshooting.md): Find the cause when an application does not answer as you expect.
