# Port Detection

If you just want to detect which port your program started listening on, you can do this with the `tuna detect` command. A time is allocated for detection, by default 5 seconds, but this behavior can be defined using the `--seconds` flag or the `TUNA_DETECT_SECONDS` environment variable. After this period expires, tuna will terminate along with all child processes.

Example run:

```shell
tuna detect -- nc -l 23554

```

Example output:

```shell
tuna detect -- nc -l 23554
INFO[16:18:12] Waiting for available ports...
INFO[16:18:12] 5
INFO[16:18:13] 4
INFO[16:18:13] Found port: 23554
INFO[16:18:14] 3
INFO[16:18:15] 2
INFO[16:18:16] 1
INFO[16:18:17] Here is your tunnel commands:
INFO[16:18:17] 1. tuna tcp 23554

```

![tuna\_detect](/en/assets/images/tuna_detect-35f718721bdbb52c4189c38be84b54a2.gif)
