# better-hosts

> Dead simple DNS server using syntax similar to hosts file.

Latest version **0.3.1** (published 2026-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install better-hosts
pnpm add better-hosts
yarn add better-hosts
bun add better-hosts
```

Provides the command `better-hosts`.

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2026-03-01 |
| First published | 2022-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=22 |
| Dependencies | 12 |
| Unpacked size | 26.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

- npm: https://www.npmjs.com/package/better-hosts
- Repository: https://github.com/BlackGlory/better-hosts
- Homepage: https://github.com/BlackGlory/better-hosts#readme
- Issues: https://github.com/BlackGlory/better-hosts/issues
- npm.io page: https://npm.io/package/better-hosts

## Dependencies (12)

- [chalk](https://npm.io/package/chalk.md) ^5.6.2
- [commander](https://npm.io/package/commander.md) ^14.0.3
- [extra-dns](https://npm.io/package/extra-dns.md) ^0.1.8
- [ip-address](https://npm.io/package/ip-address.md) ^10.1.0
- [extra-abort](https://npm.io/package/extra-abort.md) ^0.4.1
- [extra-utils](https://npm.io/package/extra-utils.md) ^6.0.0
- [extra-logger](https://npm.io/package/extra-logger.md) ^0.8.0
- [extra-promise](https://npm.io/package/extra-promise.md) ^7.1.1
- [extra-watcher](https://npm.io/package/extra-watcher.md) ^0.2.2
- [extra-filesystem](https://npm.io/package/extra-filesystem.md) ^0.6.2
- [iterable-operator](https://npm.io/package/iterable-operator.md) ^6.0.0
- [@blackglory/prelude](https://npm.io/package/@blackglory/prelude.md) ^0.4.0

## Recent versions

- 0.3.1 (latest) — 2026-03-01
- 0.3.0 — 2026-03-01
- 0.2.5 — 2026-02-11
- 0.2.4 — 2024-12-28
- 0.2.3 — 2024-12-19
- 0.2.2 — 2024-12-19
- 0.2.1 — 2023-12-27
- 0.2.0 — 2023-12-27
- 0.1.21 — 2023-01-28
- 0.1.20 — 2022-08-14
- 0.1.19 — 2022-08-06
- 0.1.18 — 2022-08-05
- 0.1.17 — 2022-08-04
- 0.1.16 — 2022-08-01
- 0.1.15 — 2022-08-01
- … 15 more at https://npm.io/package/better-hosts/versions

## README

# better-hosts
Dead simple DNS server using syntax similar to hosts file.

## Motivations
hosts works well, until:
1. you need wildcard-based rules like `127.0.0.1 *.local-service`.
2. you need ban rules like `-example.com`.
3. you need to share records in the hosts file to other devices.
4. you don't want to have to request administrator or root privileges every time you edit it.

better-hosts solves these problems by creating a DNS server that uses the hosts file.

## Install
```sh
npm install --global better-hosts
# or
yarn global add better-hosts
```

## Usage
```sh
Usage: better-hosts [options] <filename>

Options:
  -V, --version               output the version number
  --fallback-server <server>
  --timeout <seconds>          (default: "30")
  --port <port>                (default: "53")
  --log <level>                (default: "info")
  -h, --help                  display help for command
```

Example:
```sh
better-hosts hosts.txt \
  --fallback-server=1.1.1.1:53
```

---
_Source: https://npm.io/package/better-hosts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
