I ran into this a few months ago and solved it like this:
I use a shell script that runs uvicorn for my FastAPI app on render. You have to use port 10000 AND 0.0.0.0 for host, which isn’t documented anywhere but some examples.
Here’s a shell script that can be used to start your server - invoke this as your ‘start command’ in render config.
#!/bin/bash
# my app is in main.py and the FastAPI class instance is named 'app'
uvicorn main:app --host 0.0.0.0 --port 10000
Thank you, @splatcollision!! Defining the certain host and port you’ve mentioned, worked!
It should really be mentioned in the documentation. I thought that the default port for gunicorn (8000) would be the one that’s expected from Render, since in the Flask example the deployment command was gunicorn without any arguments.