The basics:
I start pycharm locally using a "remote debugging" profile and it looks fine.
Starting debug server at port 4000
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('<my local machines public ip addr>', port=4000, suspend=False)
Waiting for connection...
On the remote server, I put the appropriate call to pycharm-debug.egg in __init__.py
(but I've tried putting it in other places in the code, too).
I start the remote server like this python manage.py runserver <remote domain name>:8000
and on the local pycharm IDE/debugger I see:
"Connected to pydev debugger (build 133.1347)"
After this, things just sit there... I don't get any feedback on where execution is and no ability in the pycharm IDE to "start/continue/run" anything.
On the remote server if I <ctrl-c>
it, I see:
File "/<path here>/pycharm-debug.egg/pydevd.py", line 1256, in settrace
File "/<path here>/pycharm-debug.egg/pydevd.py", line 1305, in _locked_settrace
My guess is that everything is connected properly but I am not seeing a way to start everything running. I have "suspend=False" so I would have expected it to start. When I try to bring up a page against the remote server, I get "not connected" so the web server is obviously not running yet (if curl http://<remote server domain>:8000
I get curl: (7) Failed connect to <remote server domain>:8000; Connection refused
). Without remote debugging, this works fine running on either my local dev machine or on the remote server.
What am I doing wrong? :) Thanks!
Details:
On remote server that is running the code/process I want to debug in main __init__.py
I have :
import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
sys.path.append(BASE_DIR + '/pycharm-debug.egg')
import pydevd
pydevd.settrace('<my local machines public ip addr>', port=4000, suspend=False)
Local pycharm IDE shows this:
Starting debug server at port 4000
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('localhost', port=4000, suspend=False) (tried with <public ip addr> for this, too.
Waiting for connection...
---- and then, after I start the remote server process: ----
Connected to pydev debugger (build 133.1347)
Other notes:
I'm at a loss as to how to "bump" anything to get things running and let me start debugging.
Thanks for trying to help.
Remote Debugging with PyCharm Last modified: 21 July 2022. Professional feature: download PyCharm Professional to try. With PyCharm you can debug your application using an interpreter that is located on the other computer, for example, on a web server or dedicated test machine.
For future googlers ... I was able to get remote debugging working, but not via this method. I just answered a similar question about this over on the pycharm forums so thought I'd update this question with the method that did work for me.
/usr/local/bin/python
). /home/<username>/.pycharm_helpers
— I can't remember if this was created automatically or not).Go to "Run / Edit Configurations..." and add a "Django Server" (plus sign at top left of dialog).
DJANGO_SETTINGS_MODULE = <app>/settings.py
). For my purposes I also needed to set HTTPS=1
./home/<username>/<xyz>/<appdir>
).Set the path mappings from your local dir to the remote dir (i.e., /Users/JohnQ/<xyz>/<appdir>=/home/<username>/<xyz>/<appdir>
).
Because I needed other 3rd party servers (like FB, etc.) to be able to hit this server using HTTPS, I used "stunnel" on my remote server – it was pretty easy to set up).
In addition to this, a handy thing to do is set up deployment confirmation as well so that you can just right-click to upload newer versions of your file (under "Tools / Deployment / Configurations...").
/
" for me. After you create it, you should just be able to right-click on any file/dir and choose "Upload to...". Note that for an initial upload I just scp'd a tar.gz up to my server to save time and I only upload via the deployment configuration for the changes I do during debugging.I have been happily using this for remote debugging for ~4 mos., so it works fine.
I had the same symptoms and "fixed" it by turning off all Python Exception Breakpoints in the View Breakpoints window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With