Skip to content
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

Default port overrides requesting a system assigned port #2926

Ben-RK opened this issue Sep 28, 2018 · 8 comments · Fixed by #2928

Default port overrides requesting a system assigned port #2926

Ben-RK opened this issue Sep 28, 2018 · 8 comments · Fixed by #2928


Copy link

Ben-RK commented Sep 28, 2018

Expected Behavior

When running a flask application with, flask should pass the '0' port down to werkzeug to use a port assigned by the operating system.

Actual Behavior

The logic in flask/ sets the port to the default 5000, which can cause port conflicts, which is the exact situation that setting port=0 should avoid. This is a regression from the behaviour exhibited in prior versions.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../lib/python3.6/site-packages/flask/", line 943, in run
    run_simple(host, port, self, **options)
  File "/.../lib/python3.6/site-packages/werkzeug/", line 814, in run_simple
  File "/.../lib/python3.6/site-packages/werkzeug/", line 774, in inner
  File "/.../lib/python3.6/site-packages/werkzeug/", line 660, in make_server
    passthrough_errors, ssl_context, fd=fd)
  File ".../lib/python3.6/site-packages/werkzeug/", line 577, in __init__
    self.address_family), handler)
  File "/.../lib/python3.6/", line 453, in __init__
  File "/.../lib/python3.6/http/", line 136, in server_bind
  File "/.../lib/python3.6/", line 467, in server_bind
OSError: [Errno 98] Address already in use


  • Python version: 3.6
  • Flask version: 1.0.2
  • Werkzeug version: 0.14.1
@davidism davidism added this to the 1.0.3 milestone Sep 28, 2018
Copy link

Makes sense. Marking this as beginner friendly, I'd be happy to review a PR.

Copy link

vorelq commented Sep 28, 2018

Hi, I'd like to try and fix this one.

Copy link

patiencedaur commented Oct 13, 2018

I think it's closed, it shows expected behavior

Copy link

Man-Jain commented Nov 5, 2018

Is this one still up for grabs ?

Copy link

No, there's a PR for it (see above)

Copy link

Man-Jain commented Nov 5, 2018

Yeah but it as inactive for over a month. That's why I asked.

Copy link

theodesp commented Dec 1, 2018

@Man-Jain you can politely ask the PR implementor to see if he can fix the PR comments otherwise you can fork his PR and try to fix it yourself if you are in a hurry.

Copy link

davidism commented Dec 1, 2018

The PR is fine, I just haven't got around to merging it.

@davidism davidism modified the milestones: 1.0.3, 1.1 Jan 7, 2019
@pallets pallets deleted a comment from ivonindza Feb 8, 2019
davidism added a commit that referenced this issue May 19, 2019
Fix #2926 `Default port overrides requesting a system assigned port`
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

Successfully merging a pull request may close this issue.

8 participants