4 months ago
Working fine on local but seems like there is an issue with environment variables we keep going in circles pleas help
This is the latest issue.
Error: '$PORT' is not a valid port number.
Error: '$PORT' is not a valid port number.
Error: '$PORT' is not a valid port number.
Error: '$PORT' is not a valid port number.
Error: '$PORT' is not a valid port number.
7 Replies
4 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 4 months ago
4 months ago
are you using a dockerfile or is railway auto-deploying? and what framework/language?
ilyassbreth
are you using a dockerfile or is railway auto-deploying? and what framework/language?
4 months ago
I am using custom Dockerfiles for deployment on Railway (not auto-deploy).
Backend Stack:
- Language: Python 3.9
- Framework: FastAPI
- Server: Gunicorn with Uvicorn workers
- Setup: I have a Dockerfile that installs requirements from requirements.txt.
The Issue: My deployment builds successfully, but crashes at runtime with
gunicorn: not found, even though
gunicornis listed in myrequirements.txt
prodhubai
_I am using_ **_custom Dockerfiles_** _for deployment on Railway (not auto-deploy)._ **_Backend Stack:_** * **_Language:_** _Python 3.9_ * **_Framework:_** _FastAPI_ * **_Server:_** _Gunicorn with Uvicorn workers_ * **_Setup:_** _I have a_ **_Dockerfile_** _that installs requirements from_ **_requirements.txt_**_._ **_The Issue:_** _My deployment builds successfully, but crashes at runtime with_ ``` gunicorn: not found ``` , even though ``` gunicorn ``` is listed in my**requirements.txt**
4 months ago
I keep getting this error "
Error: '$PORT' is not a valid port number.
Error: '$PORT' is not a valid port number.
Error: '$PORT' is not a valid port number.
Error: '$PORT' is not a valid port number.
Error: '$PORT' is not a valid port number."
4 months ago
ok the issue is you're probably setting PORT at build time , railway injects it at runtime so that breaks everything
remove these from your dockerfile if you have them:
dockerfile
ARG PORT
ENV PORT=${PORT:-8080}
EXPOSE $PORTthen use shell form for CMD (no brackets):
dockerfile
CMD gunicorn main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORTchange main:app to whatever your fastapi app is (like app.main:app if your file is app/main.py)
PORT variable doesn't exist at build time only at runtime
4 months ago
ok trying
4 months ago
same error
4 months ago
ok then check your railway service settings and remove any custom start command you have set there
it may be used instead of your dockerfile CMD and it wasn't expanding $PORT properly
go to your service settings > look for"custom start command" and delete it or leave it blank so railway uses your dockerfile CMD
i hope this help you 🙂