The Problem
socket.error: [Errno 98] Address already in use
What I'm doing
I'm testing a simple flask app with foreman start
in my local environment. The app contains a few functions but its erroring here:
if __name__ == '__main__':
app.run()
The full trace is shown below. I'm not sure what could wrong, or how the socket could already be in use on my local machine. When I run the app with python runapp.py
from the terminal everything works fine.
What I've tired.
Heroku, flask, and python sockets?
following that last question I tired to change the port it runs on by using
if __name__ == '__main__':
import os
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
But it didnt help. Any suggestions would be appreciated! I'm new to Heroku so please let me know if there is anymore information I can provided to make solving this easier. Thanks!
Stack trace of error:
22:13:45 web.1 | started with 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 already in use
22:13:45 web.1 | exited with code 1
22:13:45 system | sending SIGTERM to all processes