Trouble setting PORT in Django/Heroku Procfile using Waitress
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
...
PORT = env('PORT')
running "heroku local" produces
ValueError: invalid literal for int() with base 10: '$PORT'
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. If there is a Windows friendly syntax, would I need to use it in both .env and Procfile?
Explicitly 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")