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-8e23c3abb06dSolution:Jump to solution
then remove the start command from the service settings and set it in the dockerfile
11 Replies
Project ID:
ed8b1bed-d625-4581-9f43-8e23c3abb06d
- 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
PORT is the railway environment variable? I'm having this error
Error: Invalid value for '--port': '$PORT' is not a valid integer.
you are using a dockerfile right?
yes
Solution
then remove the start command from the service settings and set it in the dockerfile
CMD uvicorn webservice:app --host 0.0.0.0 --port $PORT
Sorry i just remember I'm currently using Docker Image instead of Dockerfile because my code have more than 171225423 bytes.
i dont see how that changes anything, update the CMD directive in the dockerfile and build a new image
Thanks!
no problem!