LPM CLI

lpm ports

Inspect local TCP ports, stop listening processes, and clear saved dev-port overrides.

lpm ports shows the service ports from the current project and reports whether each port is available.

It can also show visible TCP listeners, stop a process, or clear saved port overrides.

lpm ports [action] [target]

Quickstart with lpm.json

Define the development services and their preferred ports:

lpm.json
{
  "$schema": "https://cli.lpm.dev/schemas/lpm.json",
  "services": {
    "web": {
      "command": "vite",
      "port": 5173
    },
    "api": {
      "command": "node api.js",
      "port": 4000
    }
  }
}

Show the declared ports and their current status:

lpm ports

The table shows each service, its declared port, and whether that port is ready or listening.

Start the project. Then run lpm ports from another terminal:

# Terminal 1
lpm dev

# Terminal 2
lpm ports

An explicit port remains the listed value. If lpm dev remaps the service, this table does not show the saved replacement.

Use the startup output or lpm ports all to find the active replacement port. Use lpm ports reset to clear saved replacements.

Show the assigned port for a host-only service

If a service uses a managed hostname, you can omit its port:

lpm.json
{
  "$schema": "https://cli.lpm.dev/schemas/lpm.json",
  "proxy": {
    "port": 9443,
    "httpRedirect": false
  },
  "services": {
    "web": {
      "command": "vite",
      "host": "web.localhost"
    }
  }
}

Start the project. Then show the saved assignment from another terminal:

# Terminal 1
lpm dev

# Terminal 2
lpm ports

The host-only service appears after lpm dev saves its assigned port.

A service without port or host does not appear. A service with only readyPort also does not appear.

Examples

lpm ports                   # show ports for the current project
lpm ports list              # same as lpm ports
lpm ports all               # show all visible TCP listeners
lpm ports --all             # same as lpm ports all
lpm ports 3000              # inspect port 3000
lpm ports inspect 3000      # same as lpm ports 3000
lpm ports kill 3000         # stop the process on port 3000
lpm ports kill 3000-3010    # stop processes in an inclusive range
lpm ports kill --pid 48213  # stop a known PID
lpm ports reset             # clear saved overrides for this project

Choose an action

GoalCommand
Show ports for the current projectlpm ports
Show all visible TCP listenerslpm ports all
Inspect one portlpm ports inspect 3000
Stop the process on one portlpm ports kill 3000
Stop processes in a port rangelpm ports kill 3000-3010
Stop a known PIDlpm ports kill --pid 48213
Clear saved port overrideslpm ports reset

list, all, and inspect are read-only. A bare number inspects a port, so lpm ports 3000 equals lpm ports inspect 3000.

Project scope

Run lpm ports from the directory that contains lpm.json. The command reads lpm.json only from the current directory.

If lpm.json declares services, the command uses the service-port rules from the quickstart above.

Without declared services, LPM CLI shows visible listeners from processes whose current directory is inside the command directory.

Use lpm ports all to remove the project scope and show all visible TCP listeners.

Recipes

Restore a declared port after a conflict

Inspect the port before you stop its process. Make sure that the listener is the process that you want to stop.

lpm ports inspect 3000
lpm ports kill 3000
lpm ports reset
lpm dev

lpm ports reset clears only the saved overrides for the current project. It does not edit lpm.json or stop processes.

The next lpm dev tries the declared ports again. If a declared port remains unavailable, LPM CLI assigns another port.

Find a development server from this project

Show the ports for the current project. Then inspect the port that you want to identify.

lpm ports
lpm ports inspect 5173

If the first command shows an unexpected port, inspect that port before you stop or reset anything.

For a remapped declared service, use lpm ports all and the lpm dev startup output.

Clean a range of development ports

Review all visible listeners. Then stop the matching processes in the selected range.

lpm ports all
lpm ports kill 3000-3010

The range is inclusive. If the range contains matching listeners, LPM CLI groups them by PID and asks for confirmation.

For CI or another non-interactive environment, pass --yes:

lpm ports kill 3000-3010 --yes

CAUTION: A range kill stops entire processes. A matched process can also own listeners outside the selected range.

Stop a known PID

If you already know the PID, use --pid:

lpm ports kill --pid 48213

CAUTION: --pid stops the specified process. The process does not have to own a TCP port.

Output

Project service output

For declared services, the terminal table shows the service, port, and status. A listening status also includes the available process owner.

Use JSON to get the service name, port, and free or in_use status:

lpm ports --json

Listener output

Listener commands show the port, process, PID, project, framework, and status:

lpm ports inspect 3000
lpm ports all

Use JSON for more available process details:

lpm ports inspect 3000 --json
lpm ports all --json

JSON can also include the address, command, current directory, project directory, and uptime. Available values depend on operating-system access.

Kill behavior and safety

lpm ports kill <port> does not ask for confirmation. If you do not know the owner, inspect the port before you stop it.

Before a port kill, LPM CLI finds the PID. It then makes sure that the same PID still owns the target port.

If the owner changes, the command exits without stopping the new owner. The command also refuses to stop protected system PIDs or itself.

If a range matches processes, LPM CLI groups the ports by PID and asks for confirmation. Pass --yes to skip the prompt.

In JSON and other non-interactive runs, a matching range fails without --yes:

lpm ports kill 3000-3010 --yes --json

A bare numeric kill target is always a port. Use --pid to stop an explicit PID.

Flags

FlagApplies toEffect
--alllistShow all visible TCP listeners. This flag equals lpm ports all.
--yes, -yRange killSkip the interactive confirmation.
--pid <PID>killStop the specified PID.
--jsonAll actionsWrite machine-readable output to stdout. This is a global flag.

Platform support

LPM CLI uses the listener table from each supported operating system. System permissions can limit the visible processes and available details.

PlatformSourceAvailable details
LinuxSystem TCP tablesProject data requires access to the current directory of the process.
macOS and BSDSystem process toolsProject data requires access to the current directory of the process.
WindowsSystem network and process APIsJSON can include the image path and uptime. Generic processes do not include project data.

Windows does not expose the current directory of another process through a stable public API. Generic processes cannot include that project information.

See also

  • lpm dev — run multiple services from lpm.json
  • lpm.json — configure development services and ports
  • Port management — learn how port assignments and reservations work