ipdetecto.com logo
ipdetecto.com
My IPSpeed
Knowledge Hub
HomeKnowledge HubWhat Is Hosts File
© 2026 ipdetecto.com
support@ipdetecto.comAboutContactPrivacyTermsllms.txt
Basics
5 MIN READ
Apr 19, 2026

What Is the Hosts File?

The hosts file is a local static name-to-IP map checked by most operating systems before DNS: Windows and Unix paths, line format, precedence with resolvers and DoH, malware hijacks, and safe testing practices.

What it is

The hosts file is a plain-text list of hostname to IP address mappings maintained on each machine. Before (or alongside, depending on resolver configuration) querying DNS, many stacks consult hosts for static answers—making it a simple way to override DNS for testing, blocklists, or legacy fixed mappings.

Where it lives

OSPathEdit notes
Windows%SystemRoot%\System32\drivers\etc\hostsRequires elevation for standard editors; mind 64-bit editor redirection on WOW64
Linux / macOS/etc/hostsRoot-owned; use sudo with care

Line format

Each non-comment line is typically IP-address hostname [aliases…]. Lines starting with # are comments. Multiple names can share one IP; duplicate conflicting lines create confusion—keep one authoritative mapping per hostname you care about.

Resolver interaction

On Windows, the DNS Client service uses hosts together with cached lookups and configured DNS servers. Applications that implement DNS-over-HTTPS or their own resolver may bypass hosts, which surprises testers who expect a global override. After edits, ipconfig /flushdns clears the client cache but does not change remote resolver behavior.

Security and hygiene

Malware often hijacks hosts to redirect banking sites. Enterprise agents sometimes monitor the file. Prefer temporary entries for dev testing, document changes in tickets, and remove stale overrides to avoid “works on my machine” DNS ghosts.

Related: How DNS works, Flush DNS cache, What is an FQDN, Windows ipconfig explained.

Frequently Asked Questions

Q.Does the hosts file override public DNS?

For many traditional system resolver calls, yes—the local mapping wins. Applications with built-in DNS-over-HTTPS or hard-coded resolvers may ignore hosts, so test with the same client you care about.

Q.Why are my hosts changes ignored on Windows?

Common causes: editing the wrong file under SysWOW64 redirection, insufficient privileges so the editor saved elsewhere, trailing spaces in the hostname, or an application bypassing the OS resolver.

Q.Do I need to reboot after editing hosts?

Usually no—new connections pick up changes. If a long-lived process caches DNS internally, restart that process; flush the Windows DNS client cache with ipconfig /flushdns when testing system-wide behavior.

Q.Can I map a hostname to multiple IPs?

You can list multiple lines for the same name with different IPs, but behavior is undefined for clients that expect one address—use load balancers or proper DNS records instead for production traffic shaping.

Q.Is hosts the same as a DNS A record?

Conceptually similar (name to IPv4), but hosts is local-only and not replicated. Authoritative DNS on the internet still governs everyone else unless they share your same hosts file.

Q.How do I block a site with hosts?

Point the hostname to 127.0.0.1 or 0.0.0.0—this is a blunt instrument; browsers with secure DNS may still resolve differently, and HTTPS will fail with certificate errors if anything answers locally.

Q.Does IPv6 use hosts?

Yes—entries can use literal IPv6 addresses (often bracketed in URLs, not in the hosts file itself). Common templates include ::1 for localhost alongside 127.0.0.1.

Q.Who should edit hosts in a company?

Prefer IT-managed configuration management or internal DNS zones. Ad-hoc hosts edits on servers complicate audits—treat hosts as a break-glass testing tool unless centrally governed.
TOPICS & TAGS
hosts fileC:\Windows\System32\drivers\etc\hostsstatic DNSoverride DNShosts file Windowsetc hosts