Skip to content

Better port 0 handling #2848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

RobWalt
Copy link

@RobWalt RobWalt commented Apr 8, 2025

If a user chooses to use port 0, then the operating system will choose one of the available ports automatically. This is very useful in cases where you want to allow a zola serve for a broader user base which might already bind a subset of their ports and if you don't know which ones they might use.

This feature was already supported by zola, however, the printed output just printed port 0 and didn't report which port the operating system actually chose.

Example output of zola serve -p 0 before the change

Web server is available at http://127.0.0.1:0 (bound to 127.0.0.1:0)

Example output of zola serve -p 0 after the change

Web server is available at http://127.0.0.1:37327 (bound to 127.0.0.1:37327)

IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.

The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.

Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?

If a user chooses to use port 0, then the operating system will choose
one of the available ports automatically. This is very useful in cases
where you want to allow a `zola serve` for a broader user base which
might already bind a subset of their ports and if you don't know which
ones they might use.

This feature was already supported by zola, however, the printed output
just printed port 0 and didn't report which port the operating system
actually chose.

Example output of `zola serve -p 0` before the change

```
Web server is available at http://127.0.0.1:0 (bound to 127.0.0.1:0)
```

Example output of `zola serve -p 0` after the change

```
Web server is available at http://127.0.0.1:37327 (bound to 127.0.0.1:37327)
```
@Keats
Copy link
Collaborator

Keats commented Apr 13, 2025

Can you do the PR on the next branch instead?

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