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