[Python] API server not reachable when I swarp `localhost` into `192.168.31.251`(my computer...

Discussão em 'Python' iniciado por Stack, Fevereiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    Basicly, I am running fastAPI on Python3,WSL2.I cannot connect to the server after I used http://my-IP-addr:11451 instead of http://localhost:11451

    According to ChatGPT's advice,I change my starting args as below to allow WLAN access:

    uvicorn.run(app, host="0.0.0.0", port=11451)


    And referring to Microsoft's words, I enable mirror network for WSL and configure the firewall. (i.e. running this in powershell)

    Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow


    here is the screenshot of the server: enter image description here

    and here is the comparation of the diffrence: enter image description here

    my project's repo is here: https://github.com/Lucas2011wastaken/latex2svgAPI

    can some one help me plz i am struggling with this for 5 hrs.

    try:

    try to replace localhost with my-ip-addr.

    expect:

    can connect to the server and give the same output as susal.

    problems:

    curl: (28) Failed to connect to 192.168.31.251 port 11451 after 21035 ms: Could not connect to server

    Continue reading...

Compartilhe esta Página