I have my code starting as such:
if __name__ == "__main__":
uvicorn.run(
app,
host="0.0.0.0",
port=3001, # Desired port.
)
I'm starting my Uvicorn/FastAPI app by running with no port:
uvicorn main:app
But the default port when starting is 8000; default when no port specified.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
It seems like my port=3001 is ignored in the actual Python code.
From what I understand, the code is specified when no port is specified in the terminal command.
I get the desired port when I specify port in the terminal:
uvicorn main:app --port 3001
Things I've done
- Read https://www.uvicorn.org/settings
- See FastAPI/uvicorn not working when specifying host (somewhat unrelated)
- Try multiple ports (3001, 8001)