python - Socket.error with foreman start: Tesing deploying a simple flask app to Heroku -
the problem
socket.error: [errno 98] address in use
what i'm doing
i'm testing simple flask app foreman start
in local environment. app contains few functions erroring here:
if __name__ == '__main__': app.run()
the full trace shown below. i'm not sure wrong, or how socket in use on local machine. when run app python runapp.py
terminal works fine.
what i've tired.
heroku, flask, , python sockets?
following last question tired change port runs on using
if __name__ == '__main__': import os port = int(os.environ.get('port', 5000)) app.run(host='0.0.0.0', port=port)
but didnt help. suggestions appreciated! i'm new heroku please let me know if there anymore information can provided make solving easier. thanks!
stack trace of error:
22:13:45 web.1 | started pid 11121 22:13:45 web.1 | * running on http://127.0.0.1:5000/ 22:13:45 web.1 | traceback (most recent call last): 22:13:45 web.1 | file "hunch/hunch/hunchapp.py", line 49, in <module> 22:13:45 web.1 | app.run() 22:13:45 web.1 | file "/home/agconti/my_dev/github/hunch/venv/local/lib/python2.7/site-packages/flask/app.py", line 772, in run 22:13:45 web.1 | run_simple(host, port, self, **options) 22:13:45 web.1 | file "/home/agconti/my_dev/github/hunch/venv/local/lib/python2.7/site-packages/werkzeug/serving.py", line 706, in run_simple 22:13:45 web.1 | test_socket.bind((hostname, port)) 22:13:45 web.1 | file "/usr/lib/python2.7/socket.py", line 224, in meth 22:13:45 web.1 | return getattr(self._sock,name)(*args) 22:13:45 web.1 | socket.error: [errno 98] address in use 22:13:45 web.1 | exited code 1 22:13:45 system | sending sigterm processes
soultion:
from terminal:
heroku config:add port=33507
then change app to:
if __name__ == '__main__': import os port = int(os.environ.get('port', 33507)) app.run(host='0.0.0.0', port=port)
it seems heroku reserves flask's default port own purposes. detailed discussion can found here: deploying flask app heroku.
Comments
Post a Comment