IntelliJ IDEA 2017.3 Help

Remote Debugging

This feature is only supported in the Ultimate edition.

The following is only valid when Python Plugin is installed and enabled!

IntelliJ IDEA provides two ways to debug remotely:

Remote debug with a remote interpreter

If remote debugging is performed with a remote Python interpreter, then everything is done within a single SSH connection, and port numbers are not required.

To debug remotely using a remote interpreter, follow these general steps

  1. Make sure that a remote interpreter is configured.
  2. Launch the debug process with a regular run/debug configuration.

Remote debug with a Python Debug Server

For remote debugging, IntelliJ IDEA provides archives with pydev directory. Depending on the Python version, these archives are:

  • pycharm-debug.egg for Python up to version 2
  • pycharm-debug-py3k.egg for Python 3

This archive resides in the following location, depending on the platform:

  • Windows: under the .IntelliJIDEAXXXX.X\config\plugins\python directory of the user home.
  • *NIX: under the .IntelliJIDEAXXXX.X/config/plugins/python directory of the user home.
  • macOS: under /Users/jetbrains/Library/Application Support/IntelliJIDEAXXXX.X/python/ directory.

The process of remote debugging involves the following general steps:

To configure a remote debug server

  1. Open the Run/Debug Configuration dialog box, as described in the section Creating and Editing Run/Debug Configurations, and select the Python Remote Debug configuration type.
  2. Specify the local host name and the number of the port where the debug server will run. If you don't specify any value, IntelliJ IDEA will provide port number at random.
  3. If you are going to debug a script that resides on a remote machine, specify the source root of the remote script, and the root of the local sources to keep mapping.

To prepare for remote debugging

  1. In IntelliJ IDEA, open the local script for editing, and add the following command (you can copy it from the remote debug configuration dialog):

    pydevd.settrace(<host name>, port=<port number>)

    Also, add the corresponding import statement to your script:

    import pydevd

  2. Copy the local script to the remote location, where you want to debug it.
  3. Include the pycharm-debug.egg archive. You can do it in a number of ways, for example:
    • Add the archive to PYTHONPATH.
    • Append the archive to sys.path.
    • Just copy the pydev from the archive to the directory where your remote script resides.

To launch the debug server

If the process doesn't stop, but you still want to stop tracing and disconnect from Python Remote Debug Server, add the following function to the end of a remote script being debugged:


This function stops remote debug process that has been launched with pydevd.settrace(). Thus the Python Remote Debug Server will pass to the state of waiting for a new connection.

  1. Select the desired remote configuration:
    py remote debug
  2. Click debug, or press Shift+F9. IntelliJ IDEA launches debug server at the specified host and port, which is shown in the Console pane of the Debug tool window.

To debug a remote script

  1. Locate your remote script, and launch it as required by your specific operating system. For example, on Windows, use the command:

    python <script name>

    If the corresponding local script exists, IntelliJ IDEA opens it in the editor in the suspended mode; the first executable statement is marked with the blue stripe. Also, IntelliJ IDEA shows the frames and variables for its first executable statement in the Debug tool window. If the corresponding local script cannot be found, IntelliJ IDEA opens a dedicated editor tab, and suggests to do one of the following:

    • Edit the local and remote roots in the remote debug configuration dialog box.
    • Detect the mapping files automatically, and then select the one to be used as the local version from the list of encountered files with the matching names.
    • Download the remote file to the specified location.
  2. Step though the script, set watches and evaluate expressions.
Last modified: 6 March 2018

See Also