Python Flask [Errno 98] Address already in use


I am trying to launch a flask app, but I have the following error message :

Traceback (most recent call last):
  File "/home/moibnj/flask_2017/", line 136, in <module>
  File "/usr/local/lib/python3.5/dist-packages/flask/", line 843, in run
    run_simple(host, port, self, **options)
  File "/usr/local/lib/python3.5/dist-packages/werkzeug/", line 677, in run_simple
    s.bind((hostname, port))
**OSError: [Errno 98] Address already in use**

Thank you for you help

Because you're using See the docs here and here

I used with the recommended way :

if __name__ == '__main__':

but I heave the error mentioned above

Are you trying to run a Flask app in a console? Don't do that. It won't work. Our console servers are not able to server web applications. That's what we have the web apps tab for.

In fact on the web, I have a Something went wrong :-( page, that is why I am trying to debug on the console.

The error that is causing that page will be shown in your error log.

I am also having the same problem, but there are no errors listed in my error log. I get this same socket error when I run my app in the console, I am also using in the recommended way, and I also get the "Something went wrong :-(" page. Did you ever figure out a solution?

You can't run your app in the console. That's what web apps are for. If you get a "Something went wrong" page, you'll either have an exception in your error log or in your server log (unless your app messes with logging in some way and prevents the message from getting to the log)

[edited by admin for formatting]

from flask import Flask
import MySQLdb
app = Flask(__name__)

def homepage():
    return "hello"

if __name__=="__main__":

this code gives this error :

Traceback (most recent call last):
  File "/home/hackathon/hostel/", line 16, in <module>
  File "/usr/local/lib/python3.6/dist-packages/flask/", line 841, in run
    run_simple(host, port, self, **options)
  File "/usr/local/lib/python3.6/dist-packages/werkzeug/", line 708, in run_simple
  File "/usr/local/lib/python3.6/dist-packages/werkzeug/", line 670, in inner
  File "/usr/local/lib/python3.6/dist-packages/werkzeug/", line 564, in make_server
    passthrough_errors, ssl_context, fd=fd)
  File "/usr/local/lib/python3.6/dist-packages/werkzeug/", line 476, in __init__
    HTTPServer.__init__(self, (host, int(port)), handler)
  File "/usr/lib/python3.6/", line 453, in __init__
  File "/usr/lib/python3.6/http/", line 136, in server_bind
  File "/usr/lib/python3.6/", line 467, in server_bind
OSError: [Errno 98] Address already in use

how to solve?

Hi there, these two guides should help?

No , still getting same error.

You will generally get that error. Those pages where to explain what's happening and what you should do instead.