lpm hosts
Remove LPM-managed local-domain entries from the hosts file.
lpm hosts cleanRemoves LPM-managed hosts-file blocks left by local-domain development runs. lpm dev normally adds and removes its own project-scoped block for hosts outside localhost / *.localhost; lpm hosts clean is the explicit cleanup escape hatch for interrupted sessions or old orphaned blocks.
Examples
lpm hosts clean # prompt before removing LPM-managed blocks
lpm hosts clean --yes # remove without prompting
lpm hosts clean --json # machine-readable resultThe command only removes complete blocks that LPM created:
# >>> lpm:project-... >>>
127.0.0.1 app.test
# <<< lpm:project-... <<<It preserves unmanaged hosts-file lines, writes the first backup to ~/.lpm/hosts.bak, and rejects malformed unterminated LPM blocks instead of guessing what to delete. In non-interactive shells, pass --yes; otherwise cleanup aborts before mutation.
If the system hosts file needs elevated permission, LPM re-runs its hosts-file helper through sudo on Unix or asks for Administrator elevation through UAC on Windows after consent. If elevation is cancelled or unavailable, the command fails before guessing at a fallback.
Flags
| Flag | Effect |
|---|---|
--yes | Confirm cleanup without an interactive prompt |
--json | Emit { success, cleaned, removedBlocks, hostsFile, backupPath } on stdout |