Skip to content

Fix Coast assigning ports already in use#118

Merged
jamiesunderland merged 1 commit intocoast-guard:mainfrom
GregPeden:patch/fix-occupied-port-assignment
Mar 23, 2026
Merged

Fix Coast assigning ports already in use#118
jamiesunderland merged 1 commit intocoast-guard:mainfrom
GregPeden:patch/fix-occupied-port-assignment

Conversation

@GregPeden
Copy link
Contributor

I found Coast was trying to assign ports already in use, leading to creating new coast environments sometimes failing randomly.

Coast was pre-allocating dynamic ports by doing a quick bind() probe and then immediately releasing the socket in port_manager.rs. That means “this port was free a moment ago,” not “this port is reserved.” On WSL there’s a second wrinkle: DinD publishes to 127.0.0.1 in dind.rs, and Docker Desktop’s Windows-side /forwards/expose layer can reject a port even when the Linux-side probe in WSL says it looks available.

I patched the run path in provision.rs so container creation/start now retries with a fresh set of dynamic ports when Docker reports a publish conflict, and I also made per-run port selection unique within a single instance in provision.rs.

@jamiesunderland
Copy link
Contributor

👀

Copy link
Contributor

@jamiesunderland jamiesunderland left a comment

Choose a reason for hiding this comment

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

Going to merge, will QA a bit tonight on mac, make sure nothing is wrong before putting out a fix. Thanks for finding and putting up a fix.

@jamiesunderland jamiesunderland merged commit 018bdd7 into coast-guard:main Mar 23, 2026
2 checks passed
@GregPeden
Copy link
Contributor Author

Yes check it on macos please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants