# Ports
Dupin lists the ports your processes listen on and the process holding each, opens a web server's port in the browser, and stops the process when you ask.
## Open it
Switch on **Ports** in Settings → Extensions, then type `port` Space, and a port number, a program's name or a PID, such as `port 3000` or `port node`.
## What you see
- One row per port and process: the port, then the program, its PID and the addresses it listens on, with TCP or UDP at the row's end.
- A port a process listens on over both IPv4 and IPv6 is one row with both addresses.
- The list as `lsof` reported it within the last 2 seconds: while the panel shows it, Dupin asks again every 2 seconds, and typing never waits for that.
## What you can do
↩ opens a TCP port in the browser; → or ⌘K lists the rest:
| Key / action | What it does |
| ------------------- | ----------------------------------------------------------------------------- |
| **Open in Browser** | Opens `http://localhost:`, for TCP |
| **Copy Address** | Copies `localhost:` |
| **Copy Port** | Copies the port number |
| **Show Process** | Opens [Processes](./processes.md) with the PID typed, which lists the process |
| **Terminate** | Asks the process to quit (`SIGTERM`), after you confirm |
Other keys: [Keys](../usage.md#keys).
## Notes
- Off by default, since it runs `lsof` and `kill`. Once it is on, the panel asks you to allow each program the first time it would run it; the ones that list run in the background, while you look at the list, and the rest only for an action you chose.
- macOS shows `lsof` only your own processes' sockets, so the list never has another user's or the system's ports.
- Connected and unbound UDP sockets listen on nothing, so they are left out.
- Before Terminate signals, Dupin checks that the PID still runs the program that listened, and refuses launchd and Dupin itself.
## Configuration
Ports has no setting in `config.toml`. Turn it on or off in Settings → Extensions, or ahead of time in `extension-grants.toml` beside `config.toml` ([Declaring them with Nix](./extensions.md#declaring-them-with-nix)):
```toml
version = 1
[packages."bundled:port"]
enabled = true
```
Extension scopes
| Scope | Runs | When |
| ---------------- | ----------------------------------------------------------- | -------------------------------------------------------- |
| `exec:sockets` | `/usr/sbin/lsof -nP +c 0 -iTCP -sTCP:LISTEN -iUDP -F cnPpu` | When Dupin asks for the list, without an action of yours |
| `exec:identify` | `/bin/ps -o comm= -p ` | Before Terminate |
| `exec:terminate` | `/bin/kill -TERM ` | For Terminate |
Each runs without a shell; only the PID is filled in, and it can't start with `-`.
How it works and changing it
The list is TypeScript in [`extensions/port`](../../extensions/port), whose `items()` runs `lsof` through a [`background` exec profile](./extension-permissions.md#exec). To change it, run `dupin ext eject port` and edit the copy, which is then your own extension, as [Overriding a built-in](./extensions.md#overriding-a-built-in) describes.