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

FastAPI VS Code Tutorial missing instructions on customizing port for launching api code #24591

Closed
arbinarybard opened this issue Oct 13, 2024 · 1 comment
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@arbinarybard
Copy link

arbinarybard commented Oct 13, 2024

Does this issue occur when all extensions are disabled?: N/A

  • VS Code Version: 1.94.2
  • OS Version: Windows 11 23H2

Steps to Reproduce:

  1. Follow the instructions to setup FastAPI application: https://code.visualstudio.com/docs/python/tutorial-fastapi
  2. Launch the debugging session using F5 for the python file
  3. If Port 8000 is already used by another program, it throws following error
    ERROR: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

There is no instruction in this page as to how to resolve this issue. The solution is to create a custom "launch.json" under .vscode folder that allows overriding port for uvicorn module. This resolves the issue while launching python file using F5.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: FastAPI",
            "type": "debugpy",
            "request": "launch",
            "module": "uvicorn",
            "args": [
                "groceries-plugin.main:app",
                "--port",  // This option is for overriding port
                "20000", // Custom port number to avoid [WinError 10013] error
                "--reload"
            ],
            "jinja": true
        }
    ]
}
@karthiknadig karthiknadig transferred this issue from microsoft/vscode Dec 12, 2024
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Dec 12, 2024
@cwebster-99
Copy link
Member

Thanks for filing this issue! I created a PR in our docs repo to address microsoft/vscode-docs#7856

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants