Free SSH port is not automatically assigned
- Dominant language
- Go
- Stars
- 21.9k
- Forks
- 957
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 53
Description
### Description
- Start an instance
- Stop an instance
The error seems pretty clear:
ERRO[0053] [hostagent] virtual network error: "cannot add network services: listen tcp 127.0.0.1:60022: bind: address already in use"
So as far as I can tell the port wasn't released when the instance was stopped. At the same time no other port is being used instead when starting it again.
I would expect a different, available port to be used, as explained in the default configuration i.e.:
```yaml
ssh:
# A localhost port of the host. Forwarded to port 22 of the guest.
# 🟢 Builtin default: 0 (automatically assigned to a free port)
# NOTE: when the instance name is "default", the builtin default value is set to
# 60022 for backward compatibility.
localPort: 0
```
Actually adding a different port explicitly works around this and allows the instance to start up again just fine.
Contributor guide
Research direction
Reproduce the start/stop sequence and trace the hostagent network-services handling for the ssh.localPort setting shown in the default configuration. Confirm that restarting an instance with localPort 0 selects an available localhost port rather than reusing the occupied one, and add or update coverage if the relevant test location is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100