Skip to content

Conversation

norio-nomura
Copy link
Contributor

@norio-nomura norio-nomura commented Oct 7, 2025

Add reporting for the "failed to listen tcp" error.
Additionally, it should print information about the processes listening on the failed ports.

e.g.

$ socat TCP-LISTEN:2020,bind=127.0.0.1,fork /dev/null&
$ socat TCP-LISTEN:4040,bind=127.0.0.1,fork /dev/null&
$ hack/test-port-forwarding.pl default
✅ Not forwarding TCP 127.0.0.2:3000
✅ Forwarding TCP from 127.0.0.3:3001 to 127.0.0.1:2001
✅ Forwarding TCP from 0.0.0.0:3002 to 127.0.0.1:2002
✅ Not forwarding TCP 0.0.0.0:3010
✅ Not forwarding TCP 127.0.0.1:3011
❌ Forwarding TCP from 127.0.0.2:3020 to 127.0.0.1:2020
   Guest received: ''
✅ Forwarding TCP from 127.0.0.1:3021 to 127.0.0.1:2021
✅ Forwarding TCP from 0.0.0.0:3022 to 127.0.0.1:2022
✅ Forwarding TCP from [::]:3023 to 127.0.0.1:2023
✅ Forwarding TCP from [::1]:3024 to 127.0.0.1:2024
✅ Forwarding TCP from 127.0.0.1:3030 to 192.168.12.19:2030
✅ Forwarding TCP from 0.0.0.0:3031 to 192.168.12.19:2031
✅ Forwarding TCP from [::]:3032 to 192.168.12.19:2032
✅ Forwarding TCP from [::1]:3033 to 192.168.12.19:2033
✅ Forwarding TCP from 127.0.0.1:300 to 127.0.0.1:300
✅ Forwarding TCP from 127.0.0.1:310 to 0.0.0.0:310
✅ Forwarding TCP from 192.168.5.15:4000 to 192.168.12.19:4000
✅ Forwarding TCP from [::1]:4010 to [::]:4010
✅ Forwarding TCP from 127.0.0.1:4020 to 192.168.12.19:4020
✅ Forwarding TCP from 127.0.0.2:4021 to 192.168.12.19:4021
✅ Forwarding TCP from 192.168.5.15:4022 to 192.168.12.19:4022
✅ Forwarding TCP from 0.0.0.0:4023 to 192.168.12.19:4023
✅ Forwarding TCP from [::]:4024 to 192.168.12.19:4024
✅ Forwarding TCP from [::1]:4025 to 192.168.12.19:4025
✅ Forwarding TCP from 127.0.0.1:4030 to 192.168.12.19:4030
✅ Forwarding TCP from 127.0.0.2:4031 to 192.168.12.19:4031
✅ Forwarding TCP from 192.168.5.15:4032 to 192.168.12.19:4032
✅ Forwarding TCP from 0.0.0.0:4033 to 192.168.12.19:4033
✅ Forwarding TCP from [::]:4034 to 192.168.12.19:4034
✅ Forwarding TCP from [::1]:4035 to 192.168.12.19:4035
❌ Forwarding TCP from 0.0.0.0:4040 to 127.0.0.1:4040
   Guest received: ''
✅ Forwarding TCP from [::]:4041 to 127.0.0.1:4041
✅ Not forwarding TCP 127.0.0.1:4043
✅ Not forwarding TCP 192.168.5.15:4044
✅ Forwarding TCP from 127.0.0.1:5000 to /Users/norio/.lima/default/sock/port5000.sock
⚠️  failed to listen tcp: listen tcp 127.0.0.1:2020: bind: address already in use
⚠️  failed to listen tcp: listen tcp 127.0.0.1:4040: bind: address already in use
COMMAND   PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
socat1  76346 norio    5u  IPv4 0x4a9052b6dc39e98b      0t0  TCP localhost:2020 (LISTEN)
socat1  76381 norio    5u  IPv4 0x35a18a4bd36fb075      0t0  TCP localhost:4040 (LISTEN)

Add reporting for the "failed to listen tcp" error.
Additionally, it should print information about the processes listening on the failed ports.

e.g.
```console
$ socat TCP-LISTEN:2020,bind=127.0.0.1,fork /dev/null&
$ socat TCP-LISTEN:4040,bind=127.0.0.1,fork /dev/null&
$ hack/test-port-forwarding.pl default
✅ Not forwarding TCP 127.0.0.2:3000
✅ Forwarding TCP from 127.0.0.3:3001 to 127.0.0.1:2001
✅ Forwarding TCP from 0.0.0.0:3002 to 127.0.0.1:2002
✅ Not forwarding TCP 0.0.0.0:3010
✅ Not forwarding TCP 127.0.0.1:3011
❌ Forwarding TCP from 127.0.0.2:3020 to 127.0.0.1:2020
   Guest received: ''
✅ Forwarding TCP from 127.0.0.1:3021 to 127.0.0.1:2021
✅ Forwarding TCP from 0.0.0.0:3022 to 127.0.0.1:2022
✅ Forwarding TCP from [::]:3023 to 127.0.0.1:2023
✅ Forwarding TCP from [::1]:3024 to 127.0.0.1:2024
✅ Forwarding TCP from 127.0.0.1:3030 to 192.168.12.19:2030
✅ Forwarding TCP from 0.0.0.0:3031 to 192.168.12.19:2031
✅ Forwarding TCP from [::]:3032 to 192.168.12.19:2032
✅ Forwarding TCP from [::1]:3033 to 192.168.12.19:2033
✅ Forwarding TCP from 127.0.0.1:300 to 127.0.0.1:300
✅ Forwarding TCP from 127.0.0.1:310 to 0.0.0.0:310
✅ Forwarding TCP from 192.168.5.15:4000 to 192.168.12.19:4000
✅ Forwarding TCP from [::1]:4010 to [::]:4010
✅ Forwarding TCP from 127.0.0.1:4020 to 192.168.12.19:4020
✅ Forwarding TCP from 127.0.0.2:4021 to 192.168.12.19:4021
✅ Forwarding TCP from 192.168.5.15:4022 to 192.168.12.19:4022
✅ Forwarding TCP from 0.0.0.0:4023 to 192.168.12.19:4023
✅ Forwarding TCP from [::]:4024 to 192.168.12.19:4024
✅ Forwarding TCP from [::1]:4025 to 192.168.12.19:4025
✅ Forwarding TCP from 127.0.0.1:4030 to 192.168.12.19:4030
✅ Forwarding TCP from 127.0.0.2:4031 to 192.168.12.19:4031
✅ Forwarding TCP from 192.168.5.15:4032 to 192.168.12.19:4032
✅ Forwarding TCP from 0.0.0.0:4033 to 192.168.12.19:4033
✅ Forwarding TCP from [::]:4034 to 192.168.12.19:4034
✅ Forwarding TCP from [::1]:4035 to 192.168.12.19:4035
❌ Forwarding TCP from 0.0.0.0:4040 to 127.0.0.1:4040
   Guest received: ''
✅ Forwarding TCP from [::]:4041 to 127.0.0.1:4041
✅ Not forwarding TCP 127.0.0.1:4043
✅ Not forwarding TCP 192.168.5.15:4044
✅ Forwarding TCP from 127.0.0.1:5000 to /Users/norio/.lima/default/sock/port5000.sock
⚠️  failed to listen tcp: listen tcp 127.0.0.1:2020: bind: address already in use
⚠️  failed to listen tcp: listen tcp 127.0.0.1:4040: bind: address already in use
COMMAND   PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
socat1  76346 norio    5u  IPv4 0x4a9052b6dc39e98b      0t0  TCP localhost:2020 (LISTEN)
socat1  76381 norio    5u  IPv4 0x35a18a4bd36fb075      0t0  TCP localhost:4040 (LISTEN)
```

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Oct 7, 2025
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 7a4128f into lima-vm:master Oct 7, 2025
37 checks passed
@norio-nomura norio-nomura deleted the test-port-forwarding.pl-print-failed-to-listen-tcp branch October 7, 2025 03:30
@norio-nomura
Copy link
Contributor Author

Thanks! 🙏🏻
I was considering how to make it fail intentionally to add a commit and check the operation.
I’ll check the future jobs and ensure they work as intended in case of failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants