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
Percy13mo ago
Project ID: ed8b1bed-d625-4581-9f43-8e23c3abb06d
Brody
Brody13mo 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
Sapoperro13mo 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
Brody13mo ago
you are using a dockerfile right?
Sapoperro
Sapoperro13mo ago
yes
Solution
Brody
Brody13mo ago
then remove the start command from the service settings and set it in the dockerfile
Brody
Brody13mo ago
CMD uvicorn webservice:app --host 0.0.0.0 --port $PORT
Sapoperro
Sapoperro13mo ago
Sorry i just remember I'm currently using Docker Image instead of Dockerfile because my code have more than 171225423 bytes.
Brody
Brody13mo ago
i dont see how that changes anything, update the CMD directive in the dockerfile and build a new image
Sapoperro
Sapoperro13mo ago
Thanks!
Brody
Brody13mo ago
no problem!
Want results from more Discord servers?
Add your server