Skip to content

Fix moto server port conflict - #292

Merged
HonahX merged 1 commit into
apache:mainfrom
kevinjqliu:kevinliu/fix-moto-server
Jan 22, 2024
Merged

Fix moto server port conflict#292
HonahX merged 1 commit into
apache:mainfrom
kevinjqliu:kevinliu/fix-moto-server

Conversation

@kevinjqliu

@kevinjqliukevinjqliu commented Jan 21, 2024

Copy link
Copy Markdown
Contributor

This PR changes the default moto server port from 5000 to 5001. Port 5000 is used by AirPlay Receiver on MacOS.

The is_port_in_use function is used to check if the port is available first before starting the moto server. Moto server errors out silently when the port is already in use. This will cause tests to fail with client errors even though the issue is the moto server.

For more details, see Issue #291

@HonahXHonahX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks for the fix. @kevinjqliu.

@HonahX
HonahX merged commit 1befad7 into apache:mainJan 22, 2024
@kevinjqliu
kevinjqliu deleted the kevinliu/fix-moto-server branch January 22, 2024 00:17
blackmwk pushed a commit to apache/iceberg-rust that referenced this pull request Jan 30, 2026
## Which issue does this PR close?
- Closes #.
## What changes are included in this PR?
This PR changes the default moto server port from `5000` to `5001`. Port
5000 is used by AirPlay Receiver on MacOS.
The same was done in pyiceberg:
apache/iceberg-python#292
## Are these changes tested?
Yes locally. I also did a global search for 5000
kevinjqliu pushed a commit that referenced this pull request Aug 10, 2026
…3759)
The `moto_server` session fixture hardcoded port 5001 and pre-bound a
socket to it purely to detect conflicts (added in #292). This is still
flaky: when tests run in parallel (e.g. multiple CI jobs on a shared
runner) or when a previous run leaves the port in TIME_WAIT, the pre-bind
raises `OSError: [Errno 98] Address already in use`, failing the whole
test session at fixture setup.
Bind to port 0 instead so the OS assigns a free ephemeral port, and read
the actual bound port back via moto's `get_host_and_port()`. This removes
the collision and the now-unnecessary pre-bind check (and the `socket`
import). The fixture return annotation is corrected to `Generator[...]`
since it yields.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for freeto 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

@kevinjqliu@HonahX