Skip to content

Debugging: ConnectionRefusedError with debugpy #84

Closed

Description

@tseyde

Environment data

  • VS Code version: 1.43.1
  • Extension version (available under the Extensions sidebar): 2020.3.69010
  • OS and version: Ubuntu 16.04
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6, Anaconda

Error

File "/home/{user}/.vscode/extensions/ms-python.python-2020.3.69010/pythonFiles/lib/python/debugpy/no_wheels/debugpy/launcher/../../debugpy/launcher/__init__.py", line 27, in connect
    sock.connect(("127.0.0.1", launcher_port))
ConnectionRefusedError: [Errno 111] Connection refused

Work-around

Reverting back to previous version removes errors. The previous version uses "new_ptvsd" instead of "debugpy".

Activity

  1. int19h commented on Mar 24, 2020

    @int19h
    Contributor

    We'll need debugpy logs to diagnose this properly - can you please add "logToFile": true to your launch.json configuration, and then check ~/.vscode/extensions/ms-python* for files named debugpy*.log?

  2. int19h commented on Mar 25, 2020

    @int19h
    Contributor

    Also, can you try this with other Python versions (e.g. the global system one - /usr/bin/python3), and see if that still fails in the same manner?

  3. tysonpaul89 commented on Mar 26, 2020

    @tysonpaul89

    I am also facing the same issue. I am also in Ubuntu 16.04 LTS.

    I tried to downgrade the python extension to previous versions, but then the debugger will not start(no error shown on this case just. Terminal will show the initial debug command and it will not get executed).

    The issue is there in python2.7 and python3.6 versions.

    Debuggy logs for python2.7:

    debugger.vscode_16c4c91a-991a-48dc-8838-ba4fb58349ae.log
    debugpy.adapter-15275.log
    debugpy.launcher-15285.log

    Debuggy logs for python3.6:

    debugger.vscode_5e68b1d1-d3f3-4248-a874-029aa309ad5d.log
    debugpy.adapter-16073.log
    debugpy.launcher-16097.log

    I suspect this an OS related issue because on my laptop which is using Ubuntu 18.04 LTS doesn't have this issue.

    This my launch.json.

    {
       "version":"0.2.0",
       "configurations":[
          {
             "name":"Python: Current File",
             "type":"python",
             "request":"launch",
             "program":"${file}",
             "console":"integratedTerminal",
             "pythonPath":"/Projects/xxx/xxx/env/bin/python"
          },
          {
             "name":"Python: Django 8000",
             "type":"python",
             "request":"launch",
             "program":"${workspaceFolder}/manage.py",
             "console":"integratedTerminal",
             "pythonPath":"/Projects/xxx/xxx/env/bin/python",
             "args":[
                "runserver",
                "--noreload",
                "--nothreading"
             ],
             "django":true,
            "logToFile": true
          },
          {
             "name":"Python: Django 8001",
             "type":"python",
             "request":"launch",
             "program":"${workspaceFolder}/manage.py",
             "console":"integratedTerminal",
             "args":[
                "runserver",
                "8001",
                "--noreload",
                "--nothreading"
             ],
             "django":true,
             "logToFile": true
          },
          {
             "name":"Python Celery",
             "type":"python",
             "request":"launch",
             "program":"${workspaceFolder}/manage.py",
             "console":"integratedTerminal",
             "args":[
                "celeryd",
                "-Q",
                "cronJobQueueLow_LOCAL",
                "-l",
                "info",
                "-P",
                "solo"
             ],
             "django":true
          }
       ]
    }
    

    VSCode Version:

    Version: 1.43.1
    Commit: fe22a9645b44368865c0ba92e2fb881ff1afce94
    Date: 2020-03-18T07:17:38.324Z
    Electron: 7.1.11
    Chrome: 78.0.3904.130
    Node.js: 12.8.1
    V8: 7.8.279.23-electron.0
    OS: Linux x64 4.4.0-176-generic

    Python Extension Version

    Id: ms-python.python
    Version: 2020.3.69010

  4. karthiknadig commented on Mar 26, 2020

    @karthiknadig
    Member

    Tyson Paul (@tysonpaul89) I think your issue might be this one #87 Can you check the locale settings from the comments there and confirm?

  5. int19h commented on Mar 26, 2020

    @int19h
    Contributor

    Nope, judging by the logs, it's this one.

    microsoft/vscode-python#10741 is almost certainly a dupe, although that one is on Windows.

  6. int19h commented on Mar 27, 2020

    @int19h
    Contributor

    microsoft/vscode-python#10793 is another manifestation.

  7. int19h commented on Apr 1, 2020

    @int19h
    Contributor

    The root cause for this is that we are using backlog=0 together with listen(). This normally results in a minimal connection queue size; but on Linux, if net.ipv4.tcp_syncookies is disabled, it literally means a queue of zero, so it can't accept any connections.

    Until we ship the fix, the workaround is to set net.ipv4.tcp_syncookies to 1. This can be done one-off like so:

    sudo sysctl -w net.ipv4.tcp_syncookies=1
    

    However, it will not persist between reboots. To make it persistent, edit the same value in /etc/sysctl.conf.

  8. added a commit that references this issue on Apr 1, 2020
    1b1e4db
  9. added
    bug
    on Apr 1, 2020
  10. pawamoy commented on Jan 18, 2022

    @pawamoy

    microsoft/vscode-python#10741 was marked as duplicate of this issue, but this issue was resolved as a Linux issue, while I'm experimenting it on Windows. Should I open a new one?

  11. endlesslycurious commented on Apr 21, 2022

    @endlesslycurious

    Same here, issue is not resolved for Windows as only fix given by Pavel Minaev (@int19h) was for linux..

  12. int19h commented on Apr 22, 2022

    @int19h
    Contributor

    The error message in question is very generic - it can occur on many different code paths for many different reasons. It's preferable to file separate issues for these, and close the dupes later if investigation shows that the root cause is really the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions