Error with Port Binding - FastAPI+Docker

Hi I have the following issue. After check the documentation the error is related with the port access of the container between instance. I'm using Docker with an exposed port (443) and my command is uvicorn webservice:app --host 0.0.0.0 --port 443 --reload. The deployment is done without errors but I can't access to swagger docs https://rugged-death-production.up.railway.app/docs Project Id: ed8b1bed-d625-4581-9f43-8e23c3abb06d
No description
Solution:
then remove the start command from the service settings and set it in the dockerfile
Jump to solution
11 Replies
Percy
Percy9mo ago
Project ID: ed8b1bed-d625-4581-9f43-8e23c3abb06d
Brody
Brody9mo ago
- dont use reload when on railway, it will use unnecessary resources - take a look at this https://docs.railway.app/troubleshoot/fixing-common-errors#python--uvicorn
Sapoperro
Sapoperro9mo ago
PORT is the railway environment variable? I'm having this error Error: Invalid value for '--port': '$PORT' is not a valid integer.
No description
Brody
Brody9mo ago
you are using a dockerfile right?
Sapoperro
Sapoperro9mo ago
yes
Solution
Brody
Brody9mo ago
then remove the start command from the service settings and set it in the dockerfile
Brody
Brody9mo ago
CMD uvicorn webservice:app --host 0.0.0.0 --port $PORT
Sapoperro
Sapoperro9mo ago
Sorry i just remember I'm currently using Docker Image instead of Dockerfile because my code have more than 171225423 bytes.
Brody
Brody9mo ago
i dont see how that changes anything, update the CMD directive in the dockerfile and build a new image
Sapoperro
Sapoperro9mo ago
Thanks!
Brody
Brody9mo ago
no problem!