Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

hostess Linux Build Status Windows Build Status GoDoc

An idempotent command-line utility for managing your /etc/hosts* file.

hostess add
hostess add

Why? Because you edit /etc/hosts for development, testing, and debugging. Because sometimes DNS doesn't work in production. And because editing /etc/hosts by hand is a pain. Put hostess in your Makefile or deploy scripts and call it a day.

* And C:\Windows\System32\drivers\etc\hosts on Windows.

Note: 0.4.0 has backwards incompatible changes in the API and CLI. See for details.


Download a precompiled release from GitHub, or build from source (with a recent version of Go):

git clone
cd hostess
make install


Run hostess or hostess -h to see a full list of commands.

Note The hosts file is protected. On unixes you will need to use sudo or run the hostess command as root. On Windows, you will need to run hostess from an elevated prompt (right click and Run as administrator).


On unixes, hostess follows the format specified by man hosts, with one line per IP address: localhost hostname2 hostname3

On Windows, hostess writes each hostname on its own line. localhost hostname2 hostname3


hostess may be configured via environment variables.

  • HOSTESS_FMT may be set to windows or unix to override platform detection for the hosts file format. See Behavior, above, for details

  • HOSTESS_PATH may be set to override platform detection for the location of the hosts file. By default this is C:\Windows\System32\drivers\etc\hosts on Windows and /etc/hosts everywhere else.

IPv4 and IPv6

It's possible for your hosts file to include overlapping entries for IPv4 and IPv6. This is an uncommon case so the CLI ignores this distinction. The hostess library includes logic that differentiates between these cases.


I hope my software is useful, readable, fun to use, and helps you learn something new. I maintain this software in my spare time. I rarely merge PRs because I am both lazy and a snob. Bug reports, fixes, questions, and comments are welcome but expect a delayed response. No refunds. 👻


An idempotent command-line utility for managing your /etc/hosts file.




You can’t perform that action at this time.