Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Caddy

Set Up Custom Local Domains on Windows with the Hosts File and Caddy

By Freedom251 Team · · 8 min read

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

Use two matching settings: add a hostname-to-IP entry in Windows’ hosts file, then use that identical hostname as the site address in Caddy. For a site running on the same PC, an entry such as 127.0.0.1 myapp.test sends that name to the local machine. Caddy can then serve https://myapp.test with its local certificate authority. Name resolution and certificate trust are separate: the hosts entry can be correct while the browser still warns that the HTTPS certificate is untrusted.

What this setup does

Windows checks its local hosts file before attempting normal DNS resolution for a name. A line in that file associates an IP address with one or more hostnames on that computer. It is a per-device override, not a DNS record published to your network or the public internet.

As an Amazon Associate I earn from qualifying purchases.

Caddy uses the hostname in its site address to select a configuration. It matches the request’s Host header, so the browser name, hosts-file name and Caddy site address must agree character for character. Resolving two different names to 127.0.0.1 does not make them interchangeable in Caddy.

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

For local and internal names, Caddy can issue certificates from its own local certificate authority instead of using ACME validation. The first HTTPS visit may still produce a trust warning until the Caddy root certificate is trusted by Windows and, where applicable, by the browser’s separate certificate store.

#1 Best Overall
Sale
GMKtec G3S Mini PC Intel N95 Processor (Up to 3.4GHz) 8GB RAM 256GB M.2 SSD | Mini Desktop Computer with VESA Mount for Office Home Business HTPC Proxmox, Dual 4K Display, WiFi 5, Gigabit Ethernet
  • 12th Intel Alder Lake N95 Processor – The GMKtec G3 S Mini PC is powered by the 12th Gen Intel N95 processor with 4 cores, 4 threads, 6MB cache and a burst frequency up to 3.4GHz. Compared with N100/N5105/N5100/N5095, the N95 delivers up to 36% overall performance improvement. Perfect for routine tasks, office work, and home entertainment, this compact mini desktop is more convenient than traditional bulky PCs.
  • 8GB RAM & 256GB SSD Storage – Pre-installed with 8GB DDR4 memory and a fast 256GB M.2 2242 SSD, the G3 S mini desktop offers quicker startup, smoother multitasking, and faster file transfers. Enjoy seamless performance whether you’re working on multiple applications, browsing, or streaming content.
  • Rich Interfaces & Connectivity – The G3 S mini computer comes equipped with USB 3.2 (up to 10Gbps), dual HDMI 2.0 (4K@60Hz), and a 3.5mm audio jack. With support for WiFi 5, Bluetooth 5.0, and Gigabit Ethernet (RJ45 1000MbE), it connects easily with monitors, projectors, printers, office equipment, and other peripherals, making it versatile for both home and business use.
  • Dual 4K Display Support – Featuring upgraded Intel UHD Graphics (up to 1000MHz), the G3 S supports 4K video playback and AV1 decoding for a smooth viewing experience. With dual HDMI outputs, you can connect two 4K@60Hz displays simultaneously, enabling efficient multitasking for work and entertainment.
  • GMKTEC WARRANTY - GMKtec offers a 3-year limited warranty (1 year replacement + 2 years parts replacement) for each mini PC, starting from the date of the purchase effective on all sales starting Oct. 2026. All defects due to design and workmanship are covered. With a professional after sales team always ready to attend to your needs, you can simply relax and enjoy your mini PC

Before you begin

  • Use a Windows account that can approve administrator access when saving the hosts file.
  • Install Caddy and place a Caddyfile in a known development directory.
  • Know where your application listens, such as 127.0.0.1:3000, or have static files ready for Caddy’s file server.
  • Choose a development hostname. A suffix such as .test is only an example; the hosts file does not require that suffix.

Do not use a hosts-file mapping when you need every device on a LAN to resolve the name. Each client would need its own entry; network DNS is the appropriate mechanism for shared resolution.

Step 1: Choose the hostname and destination

Decide the exact name you will type in the browser. For a service on the same Windows computer, map it to the loopback address:

127.0.0.1 myapp.test

If the service is bound to another local address, use that address instead. The IP must be the address where the web server is reachable from Windows. Keep the hostname lowercase in your notes and configuration to avoid accidental mismatches, although DNS names are generally case-insensitive.

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.

You can place a comment after an entry with a # character. Keep one mapping per line and avoid adding an extension to the file name; Windows expects a file literally named hosts.

Step 2: Edit the Windows hosts file as administrator

Microsoft documents the usual location as C:WindowsSystem32driversetchosts. The etc directory may appear to contain files without familiar extensions, and File Explorer can hide the hosts file if you filter for text documents.

Using Notepad

  1. Open the Start menu, type Notepad, right-click it and choose Run as administrator.
  2. In Notepad, select File > Open.
  3. Browse to C:WindowsSystem32driversetc.
  4. Change the file-type filter from Text Documents (*.txt) to All Files (*.*).
  5. Select hosts, add your mapping, and save.

If Notepad was not elevated, saving can fail or create a separate hosts.txt file that Windows ignores. Check the full name after saving.

Using PowerToys Hosts File Editor

Microsoft’s PowerToys Hosts File Editor provides a graphical alternative. Open the utility with its administrator mode enabled, add the IP address and hostname in separate fields, then save the entry. The elevated mode matters because the hosts file is protected under the Windows system directory. PowerToys also warns that edits can change name resolution for applications on that computer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
GEEKOM A5 2027 Edition Mini PC, Ryzen 7 7730U, 16GB RAM, 256GB NVMe SSD
  • [15W Ryzen 7 Agentic PC for Everyday Workflows] Powered by the AMD Ryzen 7 7730U processor (8 Cores, 16 Threads), the GEEKOM A5 is built for sustained productivity. It doubles as your cloud-native Agentic AI assistant, seamlessly hosting cloud AI tasks, automating office workflows, and handling intelligent document summarization without complex local deployment. Smoothly manage Microsoft Office, dozens of browser tabs, heavy Excel spreadsheets, and remote learning throughout your workday.
  • [Smart Value Now, Expandable for Tomorrow] Equipped with 16GB RAM and a fast 256GB PCIe NVMe SSD for snappy daily performance, the A5 offers incredible value. Need more space later? It features dual-slot DDR4 RAM (upgradable to 64GB) and supports an M.2 SSD up to 4TB. With an extra M.2 2242 slot and 2.5" HDD bay for up to 10TB total storage, you get the flexibility to scale your storage seamlessly as your needs grow, beating soldered LPDDR solutions.
  • [Multi-Display Connectivity for Maximum Productivity] Create a complete workstation with support for up to four displays through Dual HDMI and Dual USB-C ports, including up to 8K output via USB-C. Stay connected with Wi-Fi 6, Bluetooth 5.4, a 2.5GbE LAN port, SD card reader, and multiple USB ports for fast networking, efficient multitasking, and seamless connectivity across all your devices.
  • [Built to Stay Cool, Quiet & Reliable] More than fast, the GEEKOM A5 is built to last. A reinforced one-piece all-metal internal frame enhances structural strength, while the upgraded IceBlast 3.0 cooling system improves cooling efficiency by up to 42% with up to 35% greater airflow for quieter operation. Backed by 339 reliability tests and a 72-hour full-load aging test, it's engineered for dependable long-term performance.
  • 🏢[Business-Ready, Compact & Efficient] Pre-installed OS, the GEEKOM A5 supports Wake-on-LAN, Scheduled Power On, and Group Policy, making deployment and remote management simple for businesses. Its ultra-compact 0.6L design fits neatly behind monitors or into space-limited workstations while delivering excellent power efficiency for home offices, front desks, and commercial environments.

Verify the line

Open the file again as administrator and confirm that the line contains the intended address and exact hostname, with no accidental .txt extension or invisible typo. A hosts entry affects only the Windows installation where you made it.

Step 3: Use the same name in Caddy

Write a site block whose address is exactly myapp.test. The handler depends on whether you are serving files or forwarding to an application.

Serve a directory

myapp.test {
    root * C:pathtoyoursite
    file_server
}

Replace the path with the directory containing your HTML, CSS and other assets. Caddy’s site address is the first line; do not substitute localhost, an IP address or a second alias unless you intentionally configure additional site addresses.

Reverse-proxy an application

myapp.test {
    reverse_proxy 127.0.0.1:3000
}

The application must already be listening on the target address and port. Caddy receives the browser request for myapp.test and forwards it to the upstream service. The browser continues to use the custom hostname, which is important for testing host-based routing, cookies and redirects.

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

Multiple local names

If you need several names, give each one a hosts-file entry and a corresponding Caddy site block, or list multiple addresses on one Caddy site block when they should share identical handling. Every name you type must resolve locally and must be present in the Caddy configuration that is loaded.

Step 4: Start and reload Caddy

Open a terminal in the directory containing the Caddyfile and start Caddy with that configuration. A typical invocation is:

caddy run --config Caddyfile

Caddy serves local sites over HTTPS by default and may ask for permission to install its local root certificate. Approve that operation only if you trust the Caddy installation and understand that it adds a local certificate authority to the machine’s trust store.

Rank #3
BOSGAME E5 11 Pro Mini PC, AMD Ryzen 5300U 4C/ 8T, Business Home Office PC | 8GB DDR4 256GB M.2 2280 SSD, 2.5 GbE Dual Lan Desktop Computers, Triple Displays 4K 60Hz, Wi-Fi 5, BT 5.0, Support Linux SSH
  • 【AMD Ryzen 3 5300U CPU: Outperforms N150 & 3500U】 BOSGAME E5 mini PC is powered by the TSMC 7nm FinFET architecture AMD Ryzen 3 5300U processor (4 Cores, 8 Threads, up to 3.8GHz boost, 6MB total cache). Compared to low-end Intel N150 or 3500U chips which only have 4 single threads and throttle under load, the 5300U delivers over 30% faster multi-core speed. Run 30+ browser tabs, large Excel sheets, and Zoom meetings simultaneously without system lag.
  • 【8GB DDR4 RAM & 256GB NVMe SSD Storage】 Installed with high-speed 8GB DDR4 dual-channel memory and a fast 256GB M.2 2280 SSD, eliminating slow boot times and application loading delays. To accommodate growing data requirements, the upgradeable hardware design features dual SODIMM slots that allow you to expand memory up to 64GB RAM, ensuring smooth operation during heavy multitasking.
  • 【High-Capacity Dual M.2 SSD Storage Expansion】 Never worry about running out of space for your business files. In addition to the pre-installed 256GB system drive, the motherboard houses an extra empty internal M.2 2280 NVMe PCIe 3.0 slot. This allows you to easily add a second solid-state drive for up to an additional 2TB of storage capacity (upgrades not included) without needing to remove or reinstall the original operating system.
  • 【Radeon 6-Core Graphics & Triple 4K Displays】 Integrated with official AMD Radeon Graphics (6 Graphics Cores, 1500 MHz frequency) for casual gaming, photo editing, and crisp 4K media decoding. Featuring 1x HDMI 2.0 port, 1x DisplayPort, and 1x Full-Function Type-C port, the E5 outputs true 4K@60Hz resolution to three monitors at once. This multi-screen setup eliminates constant window-switching for traders, programmers, and office workers.
  • 【Dual 2.5GbE LAN Ports for Advanced Networking】 Experience fast wired network transmission speeds up to 2500Mbps without lagging or buffering. The integration of dual 2.5 Gigabit Ethernet ports (powered by Realtek RTL8125 controller) makes this compact computer an exceptional hardware choice for tech enthusiasts. Easily configure it into software routers, hardware firewalls (pfSense, OpnSense), home NAS servers, or local homelabs.

When you edit the Caddyfile, reload the running process rather than stopping it unnecessarily:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
caddy reload --config Caddyfile

To stop the process, use:

caddy stop

Caddy stores application data, including certificates, under its Windows data directory. Caddy documents this location as %AppData%Caddy. Avoid deleting that directory casually; doing so can remove the local CA material and cause certificates to be regenerated.

Step 5: Open the exact HTTPS address

Navigate to:

https://myapp.test

Do not test with https://127.0.0.1 if your Caddy site is named myapp.test. The IP address may reach the same process, but it sends a different host value and can select another site or produce Caddy’s default response.

If the page loads without a warning, Windows and the browser trust the Caddy local root. If a warning appears, the hosts mapping may still be working perfectly. Resolve trust separately:

  1. Confirm that Caddy completed its local CA installation and that the operation was allowed to run with the required permissions.
  2. Check the Windows trusted root store for Caddy’s local root certificate according to Caddy’s Windows trust-store documentation.
  3. Check the browser’s trust model. Some browsers use the operating-system store; others maintain a separate store or apply additional enterprise policy.
  4. Close and reopen the browser after changing trust settings, then revisit the same HTTPS hostname.

Do not replace the HTTPS URL with an HTTP URL merely to hide a trust warning if your goal is to test secure cookies, redirects or browser security behavior.

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

Hosts file or DNS: which should you use?

Question Hosts-file override DNS configuration
Where does the mapping apply? Only on the Windows computer containing the entry. To clients that use the configured DNS service.
Is a public domain required? No. You can use a development hostname without publishing it. Private DNS can use an internal namespace; public DNS normally requires a registered domain.
Can the name be reached from the internet? No. A local mapping does not publish a route or record. Only when DNS, routing, firewall rules and hosting are configured for external access.
How does Caddy issue HTTPS? Caddy can use its local CA for the internal name. For public HTTPS, Caddy’s automatic HTTPS flow generally assumes a registered public domain and reachable ports 80 and 443; internal names can still use Caddy’s local CA.
Best use One developer machine, quick local projects and isolated testing. Several computers, shared test environments or centrally managed naming.

A hosts entry is often the least disruptive choice for a single workstation because it avoids changing public DNS. It does not, however, make the name available to a phone, virtual machine or colleague’s laptop. Configure an appropriate DNS service when those clients must resolve the same hostname.

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

Troubleshooting by symptom

The browser shows the wrong site or Caddy’s default response

  • Read the hostname in the address bar and compare it with the hosts-file entry.
  • Compare that same spelling with the Caddy site address.
  • Check for an unintended port, such as myapp.test:8080, and verify which process owns the port receiving the request.
  • Reload Caddy after changing the Caddyfile.

Caddy chooses named sites from the request’s host value. Two names pointing to one IP do not automatically select one another’s site blocks.

Rank #4
Dell OptiPlex 7050 Micro Computer, Intel Quad Core i5-6500T up to 3.1GHz, 16G DDR4, 256G SSD, Windows 11 Pro 64 Bit (Renewed)
  • This Certified Refurbished product is tested and certified to look and work like new. The refurbishing process includes functionality testing, basic cleaning, inspection, and repackaging. The product ships with all relevant accessories, a minimum 90-day warranty, and may arrive in a generic box. Only select sellers who maintain a high-performance bar may offer Certified Refurbished products on Amazon.com.
  • Dell OptiPlex 7050 Micro Computer, Intel Quad Core i5-6500T up to 3.1GHz, 16G DDR4, 256G SSD.
  • Includes: USB Keyboard & Mouse, Microsoft office 30 days free trail.
  • Ports: 1 x RJ-45, 1 x HDMI, 1 x DP, 6 x USB 3.0.
  • 4K Support: Support 4K (3840x2160) Dual display, makes it easy to connect two monitors at the same time, and you can expand working Windows, mirror content, or expand a single window across multiple monitors.

The hosts file will not save

Reopen the editor with administrator rights. In Notepad, elevation must happen before opening the file. In PowerToys, enable the Hosts File Editor’s administrator mode. Confirm that Windows did not save a text-document copy with a .txt extension.

HTTPS warns that the connection is not trusted

This indicates a certificate-trust issue, not necessarily a resolution issue. Caddy’s local HTTPS depends on its local root certificate. Install or repair that root in the Windows trust store using Caddy’s documented Windows procedure, then check whether your browser uses a separate trust store. The hostname on the certificate must also match the hostname in the address bar.

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

The application works directly but not through Caddy

  • Verify the upstream address and port in reverse_proxy.
  • Confirm that the application is running and listening on the interface Caddy uses.
  • Keep the browser on the custom hostname so host-based redirects and cookies behave as they will in the intended environment.
  • Reload the Caddyfile after correcting the upstream.

A second device cannot open the hostname

That is expected from a Windows hosts-file-only setup. The entry exists on one computer and is not distributed through DNS. Use network DNS or add a deliberate mapping on every test client, while ensuring the clients can route to the machine running Caddy.

Should you flush Windows DNS cache?

The documented setup does not require presenting a particular cache-flush command. First verify the file path, spelling, Caddy site address and active configuration. If a managed environment appears to cache an old result, follow your organization’s supported Windows networking procedure rather than applying an unverified command.

Local HTTPS versus public HTTPS

Local Caddy HTTPS is designed for names that are not publicly validated. Caddy creates certificates with its local CA, so the trust relationship must be established on each client that visits the site. This is useful for development features that require HTTPS, including secure cookies, service workers and redirect testing.

Public hosting is a different workflow. Caddy’s public HTTPS quick-start assumes a registered public domain and external access to ports 80 and 443 so certificate authorities can validate the site. A hosts-file line on your Windows computer cannot satisfy those requirements or make a private service public.

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

A repeatable checklist

  1. Choose one hostname and record it exactly.
  2. Add IP-address hostname to C:WindowsSystem32driversetchosts with administrator access.
  3. Put the identical hostname in the Caddyfile.
  4. Select file_server for static content or reverse_proxy for an application.
  5. Start Caddy from the directory containing the Caddyfile.
  6. Approve and verify Caddy’s local CA trust setup.
  7. Open the HTTPS URL using the hostname, not an IP alias.
  8. After edits, run caddy reload --config Caddyfile.
  9. If another device needs the name, replace the single-host hosts override with suitable DNS.

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.

CaddyHosts fileHTTPSlocal domainsWeb developmentWindows

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.