LPM-cli

lpm hosts

Remove LPM-managed local-domain entries from the hosts file.

lpm hosts clean

Removes 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 result

The 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

FlagEffect
--yesConfirm cleanup without an interactive prompt
--jsonEmit { success, cleaned, removedBlocks, hostsFile, backupPath } on stdout

See also

  • lpm dev - registers local-domain routes and session hosts entries
  • lpm proxy - local-domain proxy daemon