[Python] Getting error "connect econnrefused 127.0.0.1:9091" while running Azure Function

Discussão em 'Python' iniciado por Stack, Maio 27, 2025.

  1. Stack

    Stack Membro Participativo

    I want to develop an HttpTrigger function in VS Code but for each attempt to run & debug, I get this error message :


    connect econnrefused 127.0.0.1:9091
    ​

    I tried a lot of solutions detailled for others questions, but none of them worked. Here are my config infos :

    • VS Code : 1.79.0
    • Python : 3.10.11
    • Azure Functions Core Tools : 4.0.5198
    • Windows 10 Pro

    Here are my files info :

    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"
    }
    ]
    }

    settings.json


    {
    "azureFunctions.deploySubpath": ".",
    "azureFunctions.scmDoBuildDuringDeployment": true,
    "azureFunctions.pythonVenv": ".venv",
    "azureFunctions.projectLanguage": "Python",
    "azureFunctions.projectRuntime": "~4",
    "debug.internalConsoleOptions": "neverOpen",
    "azureFunctions.showDeprecatedStacks": true,
    "azureFunctions.showHiddenStacks": true
    }

    tasks.json


    {
    "version": "2.0.0",
    "tasks": [
    {
    "type": "func",
    "label": "func: host start",
    "command": "host start",
    "problemMatcher": "$func-python-watch",
    "isBackground": true,
    "dependsOn": "pip install (functions)"
    },
    {
    "label": "pip install (functions)",
    "type": "shell",
    "osx": {
    "command": ". ${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
    },
    "windows": {
    "command": ". ${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
    },
    "linux": {
    "command": ". ${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
    },
    "problemMatcher": []
    }
    ]
    }

    init.py


    It is as it was generated, I do not change anything and it still doesn't work.

    import logging
    import azure.functions as func

    def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    name = req.params.get('name')
    if not name:
    try:
    req_body = req.get_json()
    except ValueError:
    pass
    else:
    name = req_body.get('name')

    if name:
    return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
    else:
    return func.HttpResponse(
    "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
    status_code=200
    )


    When I use run & debug, I get this : [​IMG]

    When I use a command line to start my function, I get this : [​IMG] [​IMG] [​IMG] [​IMG] [​IMG]

    There are many more MS_FUNCTION lines, but I think they are not useful. If someone knows how I can remove these prints, I would appreciate because no one had those when I was searching for an answer. The list of what I tried :

    • Change the port to 7071 or 9092
    • The 3 possibilities described here
    • I set the setting "terminal.integrated.shell.windows" on powershell.exe
    • Uninstall VS Code, Azure Functions Core Tools and Python, but it was useless

    Continue reading...

Compartilhe esta Página