I'm trying to deploy my Django application with Heroku (on Windows), and using Waitress (because Gunicorn no longer runs on Windows??). When I hard coded the PORT number, I was able to run it fine.
When I try to define PORT in the Procfile as an environment variable
Procfile:
web: waitress-serve --port=$PORT [projectname].wsgi:application
from .env
WEB_CONCURRENCY=2
PORT=$PORT
from settings.py
import environ
from environ import Env
env = Env()
...
PORT = env('PORT')
running "heroku local" produces
ValueError: invalid literal for int() with base 10: '$PORT'
Ultimately I'm trying to resolve a failure to bind to PORT:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT `within 60 seconds of launch`
I keep seeing mention that "$PORT" is not appropriate for Windows. However I can't figure out what I'm missing. I've seen suggestions that "%PORT%" would work for Windows, but I haven't had success. I've also tried "PORT" without symbols (as the Waitress docs seem to suggest). If there is a Windows friendly syntax, would I need to use it in both .env and Procfile?
I'm trying to deploy my Django application with Heroku (on Windows), and using Waitress (because Gunicorn no longer runs on Windows??). When I hard coded the PORT number, I was able to run it fine.
When I try to define PORT in the Procfile as an environment variable
Procfile:
web: waitress-serve --port=$PORT [projectname].wsgi:application
from .env
WEB_CONCURRENCY=2
PORT=$PORT
from settings.py
import environ
from environ import Env
env = Env()
...
PORT = env('PORT')
running "heroku local" produces
ValueError: invalid literal for int() with base 10: '$PORT'
Ultimately I'm trying to resolve a failure to bind to PORT:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT `within 60 seconds of launch`
I keep seeing mention that "$PORT" is not appropriate for Windows. However I can't figure out what I'm missing. I've seen suggestions that "%PORT%" would work for Windows, but I haven't had success. I've also tried "PORT" without symbols (as the Waitress docs seem to suggest). If there is a Windows friendly syntax, would I need to use it in both .env and Procfile?
Share Improve this question edited Mar 30 at 0:39 relp lamfred asked Mar 29 at 22:34 relp lamfredrelp lamfred 111 bronze badge1 Answer
Reset to default 0Explicitly tell you django-environs library that you are passing int not string. You can achieve that by casting the value in this format, so update your code on settings.py to look like this;
Remove the dollar sign ($) on your .env as well. Then rerun your build process.
PORT = env.int("PORT")