Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot debug flask app using pycharm

I am trying to debug my flask app but when I start my wsgi script as debug It won't connect. My wsgi.py

from flask_app import app as application

if __name__ == "__main__":
    application.run(host="0.0.0.0", port=5000)

and console message

pydev debugger: process 13472 is connecting

Connected to pydev debugger (build 143.1919)
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
pydev debugger: process 15356 is connecting

Running it normally works like a charm. How can I get any errors messages as indication to what is wrong?

EDIT:

it seems that it doesn't open the port in 5000 because when I run netstat -a and wsgi is running in debug mode, I don't see 0.0.0.0:5000 listening or timewait state anywhere. WHen run normally I can see 0.0.0.0:5000 listening

like image 518
Apostolos Avatar asked Jul 14 '26 05:07

Apostolos


1 Answers

Just had the same problem with flask 0.12.1 and PyCharm 2017.1.2.

In PyCharm I ticked the

File > Settings > Build, Execution, Deployment > Debugger > 'Can accept external connections'

box, then restarted the debugger and it is now connecting to the pydev debugger.

Note that I have since unticked the box again and restarted the debugger and it still connects, so not sure if that is actually a legit solution, but seemed to work for me.

like image 116
rlangdon Avatar answered Jul 17 '26 16:07

rlangdon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!