Running Azure Functions with VS Code instanlty fails with ECONNREFUSED

Question:

Yesterday I could run and debug my Azure Function project with VS Code. Today, when I’m hitting F5 ("Start Debugging"), a pop-up instantly appears with

connect ECONNREFUSED 127.0.0.1:9091

I believe it’s a network issue, since VS Code doesn’t even open a terminal displaying "Executing task […]".

But within VS Code I can browse the extension marketplace, run "pip install" within the terminal.

Here is my configuration:

launch.json

{
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python: Current file",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal"
            },
            {
                "name": "Azure Functions",
                "type": "python",
                "request": "attach",
                "port": 9091,
                "preLaunchTask": "func: host start"
            }
        ]
    }

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "func",
            "command": "host start",
            "problemMatcher": "$func-python-watch",
            "isBackground": true,
            "dependsOn": "pipInstall",
            "options": {
                "cwd": "${config:azureFunctions.projectSubpath}"
            }
        },
        {
            "label": "pipInstall",
            "type": "shell",
            "command": "${config:python.pythonPath} -m pip install -r requirements.txt",
            "problemMatcher": [],
            "options": {
                "cwd": "${config:azureFunctions.projectSubpath}"
            }
        }

    ]
}

settings.json

{
    "azureFunctions.deploySubpath": "azure-functions\my_project",
    "azureFunctions.projectSubpath": "azure-functions\my_project",
    "azureFunctions.scmDoBuildDuringDeployment": true,
    "azureFunctions.pythonVenv": ".venv",
    "azureFunctions.projectLanguage": "Python",
    "azureFunctions.projectRuntime": "~3",
    
    "debug.internalConsoleOptions": "neverOpen",
    "python.pythonPath": "C:\Users\myself\BigRepo\azure-functions\my_project\.venv\Scripts\python.exe",
    "powershell.codeFormatting.addWhitespaceAroundPipe": true
    //"terminal.integrated.shell.windows": "&&"
    }
Asked By: Be Chiller Too

||

Answers:

This is so weird. I edited my launch.json back and forth, sometimes it was a valid one, sometimes it was not, and now when I’m saving my original launch.json, the configuration works.

This configuration works fine:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current file",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "Azure Functions",
            "type": "python",
            "request": "attach",
            "port": 9091,
            "preLaunchTask": "func: host start"
        }
    ]
}

I’m not sure I understand what is going on.

Answered By: Be Chiller Too

Re-install everything.

It works.

Answered By: Ate Somebits

I faced this issue too, it happens when there is issue with .vscode related file, i had added variables in local.settings.json file after i removed this i was able to run. try to find .vscode / function run related files.

Answered By: Arkankhan Pathan