[Python] Pycharm remote debugger is stuck on waiting for connection when running from Pycharm...

Discussão em 'Python' iniciado por Stack, Março 2, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run in debug mode, a Python FastAPI application running in a container using PyCharm's Cloud Code plugin, but I can't get breakpoints to work.

    Setup:

    • PyCharm with Cloud Code plugin
    • Python 3.11 FastAPI application using base docker image from tiangolo/uvicorn-gunicorn-fastapi:python3.11
    • docker-desktop local deployment via Cloud Code: Kubernetes run configuration
    What happens:

    1. The container deploys successfully
    2. Port forwarding works (both for app and debug ports)
    3. The application runs normally
    4. Breakpoints are never hit - I see a background task on debugger which says "waiting for connection" [​IMG]
    Logs show this warning (not sure if relevant):


    [elon] WARN[0000] not a python launcher: unable to determine python version from "/usr/bin/env": exit status 125

    From container inspection:


    $ kubectl exec -it pod-name -- ps -ef
    root 1 0 0 13:39 pts/0 00:00:00 /dbg/python/launcher --mode pydevd --port 5678 -- /start-reload.sh
    root 13 1 0 13:39 pts/0 00:00:01 /usr/local/bin/python3.11 /usr/local/bin/uvicorn --reload --host 0.0.0.0 --port 8080 --log-level info app.web:app

    The container can successfully reach my host machine:


    kubectl exec -it pod-name -- wget -O- http://host.docker.internal:63341
    HTTP request sent, awaiting response... 404 Not Found

    Port forwarding is active


    Port forwarding pod/pod-name in namespace default, remote port 5678 -> http://127.0.0.1:5678

    Environment details:

    • PyCharm Professional 2024.3.2
    • Cloud Code plugin version 24.11.1-233-api-version-223
    • macOS Sequoia 15.3.1
    • Docker Desktop version 4.38.0 (181591)

    [​IMG] [​IMG]

    Continue reading...

Compartilhe esta Página