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

Closed
Ben-RK opened this issue Sep 28, 2018 · 8 comments

Comments

@Ben-RK
Copy link

commented Sep 28, 2018

Expected Behavior

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

Actual Behavior

The logic in flask/app.py:932 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.

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

Environment

  • 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

@davidism

This comment has been minimized.

Copy link
Member

commented Sep 28, 2018

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

@vorelq

This comment has been minimized.

Copy link
Contributor

commented Sep 28, 2018

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

@patiencedaur

This comment has been minimized.

Copy link

commented Oct 13, 2018

I think it's closed, it shows expected behavior

@Man-Jain

This comment has been minimized.

Copy link

commented Nov 5, 2018

Is this one still up for grabs ?

@ThiefMaster

This comment has been minimized.

Copy link
Member

commented Nov 5, 2018

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

@Man-Jain

This comment has been minimized.

Copy link

commented Nov 5, 2018

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

@theodesp

This comment has been minimized.

Copy link

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.

@davidism

This comment has been minimized.

Copy link
Member

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

@miguelgrinberg miguelgrinberg added question and removed question labels Jan 13, 2019

@pallets pallets deleted a comment from ivonindza Feb 8, 2019

davidism added a commit that referenced this issue May 19, 2019

Merge pull request #2928 from vorelq/2926-default-port-overrides-zero
Fix #2926 `Default port overrides requesting a system assigned port`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.