Running FastAPI from Docker - Application failed to respond even if CMD line has $PORT
kelexbot
HOBBYOP

2 years ago

Hello,
I'm running a fastAPI app from a Dockerfile.
I've updated my CMD line to be:

CMD uvicorn bot_backend.main:app --host 0.0.0.0 --reload --port $PORT

Nonetheless I still can't connect to my App from the internet. Everything is working fine locally (via docker-compose).

5 Replies

2 years ago

Aside from the reload flag, that command looks fine to me, make sure that the command is getting run as it could get overwritten in many ways, via the start command in the service settings, a Procfile, a railway.json, or a nixpacks.toml.


kelexbot
HOBBYOP

2 years ago

Well I'm deploying a regular Docker image from Github (don't have any start command or external config files).
It seems the app is running as I see some starting messages:

INFO: Will watch for changes in these directories: ['/app']
INFO: Uvicorn running on http://0.0.0.0:6355 (Press CTRL+C to quit)
INFO: Will watch for changes in these directories: ['/app']
INFO: Uvicorn running on http://0.0.0.0:6355 (Press CTRL+C to quit)


2 years ago

try without the reload flag?


kelexbot
HOBBYOP

2 years ago

Solved - I was downloading heavy file at init.
I had no error messages by the way -> are they ALL returned ?

I'm suspect some memory issues…I'm using the free plan so I suppose the underlying machine is quite small ?


2 years ago

as long as you are logging your error messages unbuffered to stderr they will be displayed in red in the deployment logs.

the free plan does limit your services to 512mb of memory and you can upgrade to hobby for 8gb of memory per service!


Loading...