Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To use a memorable local hostname such as myapp.test on Windows, add that name to the Windows hosts file and use the identical name as the site address in Caddy. The hosts entry controls where Windows sends the request; Caddy’s site address controls which configuration handles it. Caddy can then serve the site over HTTPS with its local certificate authority. Name resolution and certificate trust are separate steps, so a working hosts entry does not by itself make a browser trust the HTTPS certificate.

What this setup does

Windows checks its local hosts file before asking DNS to resolve a name. A line such as 127.0.0.1 myapp.test therefore tells that computer to send requests for myapp.test to its own loopback address. The entry is local configuration, not a DNS record: another laptop, phone, virtual machine, or colleague’s workstation will not learn the name from your file.

Caddy receives the request after Windows resolves the name. It selects a site by comparing the request’s Host value with the site address in the Caddyfile. Consequently, the browser hostname, hosts-file hostname, and Caddy site address must match exactly. Two names can point to the same IP address and still select different Caddy sites.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For local and internal names, Caddy uses its own local certificate authority rather than ACME or public DNS validation. The browser can still show a trust warning until the machine—and, depending on the browser, its separate trust store—trusts Caddy’s local root certificate.

#1 Best Overall
Windows 11 Pro Upgrade, from Windows 11 Home (Digital Download)
  • Instantly productive. Simpler, more intuitive UI and effortless navigation. New features like snap layouts help you manage multiple tasks with ease.
  • Smarter collaboration. Have effective online meetings. Share content and mute/unmute right from the taskbar (1) Stay focused with intelligent noise cancelling and background blur.(2)
  • Reassuringly consistent. Have confidence that your applications will work. Familiar deployment and update tools. Accelerate adoption with expanded deployment policies.
  • Powerful security. Safeguard data and access anywhere with hardware-based isolation, encryption, and malware protection built in.

Before you start

  • Windows with permission to edit files in C:WindowsSystem32driversetc.
  • Caddy installed and available from a terminal.
  • A hostname you will use consistently. myapp.test is only an example; no particular suffix is required.
  • A local application, static directory, or upstream service that Caddy should serve.

Decide whether the site is static or whether Caddy should proxy to a development server. That choice changes the handler in the Caddyfile, but not the hosts-file mapping.

Choose the hostname and local address

For a service running on the same Windows computer, map the hostname to loopback:

127.0.0.1 myapp.test

The IP address identifies where the service listens; the hostname is the name you will type in the browser. You may add a comment with # to document the purpose:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
127.0.0.1 myapp.test  # local development site

Do not assume that a hosts-file entry creates a domain that is reachable from the internet. It affects only the computer containing the entry. If other devices must resolve the same name, configure suitable network DNS for those clients instead of copying a single-machine workaround.

Edit the Windows hosts file as administrator

Find the file

Windows stores the file at:

C:WindowsSystem32driversetchosts

The filename is exactly hosts; it has no .txt extension. Because the file is in a protected system directory, a normal editor window may be unable to save changes.

Use an elevated text editor

  1. Open your text editor with Run as administrator. If Windows asks for consent, approve it.
  2. In the editor’s Open dialog, browse to C:WindowsSystem32driversetc.
  3. Change the file filter from text documents to all files if hosts is not visible.
  4. Open hosts, add the mapping on its own line, and save without adding an extension.

Microsoft’s PowerToys Hosts File Editor is an optional graphical alternative. Its administrator mode is designed for editing this protected file. Any editor is acceptable if it actually writes the file with elevated rights.

Check the line you added

Keep the address and hostname separated by whitespace. Avoid introducing a typo, trailing extension, or a second hostname that you do not intend to use. The name you type later must be the same sequence of characters shown here.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Microsoft OEM System Builder | Windоws 11 Pro | Intended use for new systems | Authorized by Microsoft
  • STREAMLIMED AND INTUITIVE UI | Intelligent desktop | Personalize your experience for simpler efficiency | Powerful security built-in and enabled.
  • JOIN YOUR BUSINESS OR SCHOOL DOMAIN for easy access to network files, servers, and printers.
  • OEM IS TO BE INSTALLED ON A NEW PC WITH NO PRIOR VERSION of Windows installed and cannot be transferred to another machine.
  • OEM DOES NOT PROVIDE PRODUCT SUPPORT | To acquire product with Microsoft support, obtain the full packaged “Retail” version.

Write a matching Caddyfile

Create a file named Caddyfile in a convenient development directory. The first line is the site address, and the directives inside the braces define how Caddy responds.

Quick response for a routing check

Use a response handler to prove that hostname matching works before involving an application:

myapp.test {
    respond "Caddy is serving myapp.test"
}

This test distinguishes a Caddy routing problem from an application problem. Once it responds correctly, replace respond with the handler your project needs.

Serve static files

For a directory of HTML, CSS, JavaScript, or other assets, use a root and file server:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
myapp.test {
    root * C:/dev/myapp
    file_server
}

Use forward slashes in the Windows path to keep the Caddyfile easy to read. Replace the example directory with the actual project location.

Proxy to a development server

If another process listens on a local port, pass requests through with reverse_proxy:

myapp.test {
    reverse_proxy 127.0.0.1:3000
}

The upstream application can continue listening on its usual port while browsers use the custom hostname and Caddy’s HTTPS endpoint.

Rank #3
Sale
Microsoft Windоws 11 Pro for Workstations | For advanced needs such as data/CAD/researchers | Install use on a new PC | Branded by Microsoft
  • WINDOWS 11 PRO FOR WORKSTATIONS is for people with advanced needs such as data scientists, CAD professionals, researchers, media production teams, graphic designers, and animators.
  • WINDOWS 11 PRO FOR WORKSTATIONS helps power through advanced workloads while providing server-grade data protection and performance, and includes all the features of Windows 11 Pro | Users will benefit from greater speed with faster processing and file transfers, greater resilience with server-grade storage, and the full power of high-performance hardware configurations.
  • OEM IS TO BE INSTALLED ON A NEW PC with no prior version of Windows installed and cannot be transferred to another machine | Windows 11 Pro for Workstations is required licensing for systems with Intel Xeon or AMD Opteron processors.
  • OEM DOES NOT PROVIDE SUPPORT | To acquire product with Microsoft support, obtain the full packaged “Retail” version.

Start Caddy and open the site

  1. Open a terminal in the directory containing the Caddyfile.
  2. Start Caddy with that configuration:
caddy run --config Caddyfile

Caddy serves local sites over HTTPS by default. On first use it may ask for your password because installing its local root certificate requires elevated permission.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. In the browser, visit the exact hostname, for example https://myapp.test.
  2. If you change the Caddyfile while Caddy is running, apply the change with:
caddy reload --config Caddyfile

When you are finished, stop the running Caddy process with:

caddy stop

Use the same Caddyfile path for reloads that you used to start the process so the intended configuration is replaced.

Make Caddy’s local HTTPS certificate trusted

Correct name resolution and certificate trust are independent. The hosts file can send myapp.test to 127.0.0.1 while the browser still warns that the certificate issuer is unknown.

Automatic installation

When Caddy starts local HTTPS for the first time, it may offer to install its local root certificate and request administrator approval. Accepting that prompt installs trust for the Windows environment where Caddy is running.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install the root certificate on Windows

Caddy keeps its application data under %AppData%Caddy. Its local root certificate is stored beneath the local authority directory. From an elevated Command Prompt, Caddy documents installing that certificate with Windows certutil:

certutil -addstore -f "ROOT" "%AppData%Caddypkiauthoritieslocalroot.crt"

Run the command with the same Windows account and Caddy data directory that created the certificate. If the certificate is installed for one account but Caddy is running under another, the stores may not contain the same root.

Rank #4

Account for browser-specific stores

Some browsers maintain a trust store separate from the Windows certificate store. If Windows trusts the root but a browser continues to warn, follow that browser’s certificate-import procedure and add Caddy’s local root there as well. A trust warning at this stage does not prove that the hosts mapping is wrong.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Hosts file versus DNS: which approach fits?

Consideration Windows hosts file with Caddy DNS with Caddy’s public HTTPS workflow
Where the name is resolved Only on the Windows computer containing the entry By DNS for clients that can reach the configured DNS service
Public domain registration Not required for a local mapping Uses a registered public domain
Internet reachability Local-machine scope Requires external access to ports 80 and 443 for the public setup
Certificate model Caddy local certificate authority; clients must trust its root Public certificate issuance through Caddy’s automatic HTTPS flow
Best use One developer’s local site or an isolated internal test A service intended for clients outside the local computer

The hosts-file method is useful precisely because it avoids changing public DNS. It is not a substitute for network DNS when several devices need the same name, and it does not publish a service to the internet.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot the common failure modes

The browser shows the wrong site or a default response

Compare the hostname in the address bar character by character with the hosts-file line and the Caddy site address. Caddy matches named sites using the request’s Host header. A request for www.myapp.test, for example, is not the same as a site configured only for myapp.test. Correct the names, then reload the Caddyfile.

The name resolves, but HTTPS is blocked or warns

First separate the two questions: did Windows resolve the hostname to the intended address, and does the browser trust the certificate? If the first is correct, install Caddy’s local root certificate in the Windows store and, where necessary, the browser’s separate store. Caddy’s local HTTPS does not use public ACME validation for internal names.

Windows will not save the hosts file

Close the editor, reopen it with administrator rights, and open the extensionless file from the system directory again. PowerToys Hosts File Editor can provide an administrator-mode interface. Saving a file named hosts.txt does not modify the hosts file Windows reads.

Changes to the Caddyfile do not appear

Reload the running configuration:

caddy reload --config Caddyfile

Confirm that the command targets the same file used when Caddy was started. A syntax or configuration error will prevent the new configuration from taking effect; read the terminal output and correct the indicated directive.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Another device cannot open the hostname

That behavior is expected when only one Windows hosts file was edited. The mapping is not distributed to other clients. Provide an appropriate DNS service for the network, or create equivalent local mappings on each client if that limited arrangement is acceptable.

A repeatable checklist

  • Pick one hostname and keep its spelling identical everywhere.
  • Add 127.0.0.1 hostname to the elevated Windows hosts file.
  • Use the same hostname as the Caddyfile site address.
  • Select one handler: respond for a test, file_server for static content, or reverse_proxy for an application server.
  • Start Caddy from the directory containing the Caddyfile.
  • Open https://hostname, not a different alias.
  • Trust Caddy’s local root certificate in Windows and, if needed, in the browser.
  • Reload Caddy after configuration edits and stop it when the development session ends.

This arrangement gives one Windows machine a convenient custom name and Caddy-managed local HTTPS without registering a public domain. Its deliberate boundary is scope: hosts-file resolution stays on that computer, while shared or public access requires DNS and an appropriately exposed Caddy deployment.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.