Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging: ConnectionRefusedError with debugpy #84

Closed
tseyde opened this issue Mar 22, 2020 · 10 comments
Closed

Debugging: ConnectionRefusedError with debugpy #84

tseyde opened this issue Mar 22, 2020 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@tseyde
Copy link

tseyde commented Mar 22, 2020

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".

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Mar 22, 2020
@int19h
Copy link
Contributor

int19h commented Mar 24, 2020

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?

@int19h
Copy link
Contributor

int19h commented Mar 25, 2020

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?

@tysonpaul89
Copy link

tysonpaul89 commented Mar 26, 2020

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

@karthiknadig
Copy link
Member

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

@int19h
Copy link
Contributor

int19h commented Mar 26, 2020

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

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

@int19h
Copy link
Contributor

int19h commented Mar 27, 2020

microsoft/vscode-python#10793 is another manifestation.

@int19h
Copy link
Contributor

int19h commented Apr 1, 2020

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.

int19h added a commit to int19h/debugpy that referenced this issue Apr 1, 2020
Always use backlog of at least 1 for listener sockets.

Improve launcher-related error messages in adapter.
@int19h int19h self-assigned this Apr 1, 2020
@int19h int19h added the bug Something isn't working label Apr 1, 2020
@int19h int19h closed this as completed in f263309 Apr 1, 2020
@pawamoy
Copy link

pawamoy commented Jan 18, 2022

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?

@endlesslycurious
Copy link

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

@int19h
Copy link
Contributor

int19h commented Apr 22, 2022

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
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants