hostie is a handy CLI tool that simplifies the process of adding, removing, and
listing entries in your system's hosts file (/etc/hosts on Unix, C:\Windows\System32\drivers\etc\hosts on Windows).
Perfect for developers who need to quickly map hostnames to IP addresses for local development, testing, or debugging. You no longer need to deal with manual and error-prone editing. Now, it's as simple as running a command.
Instead of manually editing your hosts file like this:
sudo nano /etc/hosts
# Navigate to the right line, be careful not to break anything...
# Add: 127.0.0.1 myapp.local
# Save and exitJust do this:
sudo hostie add 127.0.0.1 myapp.local- 🚀 Simple commands: Add, remove, and list hosts entries with ease
- 🛡️ Safe operations: Prevents accidental removal of system entries like
localhost - 🎯 Precise matching: Only exact IP+hostname combinations are affected
- 🌍 Cross-platform: Works on macOS, Linux, and Windows
- 📝 Preserves formatting: Keeps your hosts file comments and structure intact
- ✅ Duplicate prevention: Won't add the same hostname twice
- 🧪 Well-tested: 24 comprehensive tests ensure reliability
You can download the compiled binaries for hostie from the
GitHub Releases page. Choose the
binary that corresponds to your operating system and architecture, and place it
in a directory included in your system's PATH environment variable.
To install hostie using Cargo, you'll need to have Rust installed on your system. Once Rust is installed, you can install hostie with Cargo:
cargo install hostiehostie [COMMAND]add <ip> <hostname>: Add an entry to the hosts file with the specified IP and hostnameremove <ip> <hostname>: Remove the entry with the specified IP and hostname from the hosts filelist: Print the current entries in the hosts file
Add a local development site:
sudo hostie add 127.0.0.1 myapp.localRemove an entry when you're done:
sudo hostie remove 127.0.0.1 myapp.localList all current entries:
hostie listSet up multiple local services:
sudo hostie add 127.0.0.1 api.local
sudo hostie add 127.0.0.1 frontend.local
sudo hostie add 127.0.0.1 admin.localPoint to a staging server:
sudo hostie add 192.168.1.100 staging.mycompany.comOverride a production domain for testing:
sudo hostie add 127.0.0.1 api.production.comBlock a website (point to localhost):
sudo hostie add 127.0.0.1 distracting-website.com$ hostie list
127.0.0.1 localhost
127.0.0.1 myapp.local
192.168.1.100 staging.mycompany.com
::1 localhost- ✅ Prevents duplicates: Won't add the same hostname twice
- ✅ Protects system entries: Can't accidentally remove
localhost - ✅ Preserves formatting: Keeps comments and empty lines intact
- ✅ Cross-platform: Works on macOS, Linux, and Windows
- ✅ Safe operations: Only modifies exact matches, no false positives
You need to use sudo to execute the add and remove commands, as the hosts
file requires administrator privileges to modify its contents.
This project is available under the MIT License.