Ошибка Django/Heroku «Web-процессу не удалось привязаться к $PORT».
Я пытаюсь настроить проект Django/PostgreSQL для развертывания на Heroku с помощью Waitress. (Я делал это успешно только один раз, несколько лет назад, используя Guincorn).
В конечном итоге я сталкиваюсь с ошибкой
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Полный журнал ошибок выглядит следующим образом:
2025-04-09T07:09:48.289599+00:00 heroku[web.1]: State changed from crashed to starting
2025-04-09T07:09:52.235046+00:00 heroku[web.1]: Starting process with command `waitress-serve project.wsgi:application`
2025-04-09T07:09:52.781389+00:00 app[web.1]: Python buildpack: Detected 512 MB available memory and 8 CPU cores.
2025-04-09T07:09:52.781847+00:00 app[web.1]: Python buildpack: Defaulting WEB_CONCURRENCY to 2 based on the available memory.
2025-04-09T07:09:53.244456+00:00 app[web.1]: INFO:waitress:Serving on http://0.0.0.0:8080
2025-04-09T07:10:52.357945+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2025-04-09T07:10:52.370446+00:00 heroku[web.1]: Stopping process with SIGKILL
2025-04-09T07:10:52.421789+00:00 heroku[web.1]: Process exited with status 137
2025-04-09T07:10:52.445044+00:00 heroku[web.1]: State changed from starting to crashed"
Сначала я думал, что это проблема с определением PORT, но после того, как я убрал это из своего Procfile, кажется, что Heroku определяет PORT локально, и поэтому эта проблема может быть решена?
Я надеюсь, что у кого-то есть идеи, что может быть причиной «не удалось привязать к $PORT». Может ли это быть проблема с DATABASE_URL? Я использую SSL от Heroku, но так и не разобрался с этими настройками.
Профиль:
web: waitress-serve project.wsgi:application
.env:
WEB_CONCURRENCY=3
PORT=PORT
SECRET_KEY=[text-of-secret-key]
И мои файлы настроек, base.py и heroku.py base.py
base.py
(Я не уверен, что мое условное определение DATABASES необходимо, но я получаю ту же ошибку, если опустить первое условие heroku.)
heroku.py
import environ
#import dj_database_url
# If using in your own project, update the project namespace below
from project.settings.base import *
env = environ.Env(
# set casting, default value
DEBUG=(bool, True)
)
# False if not in os.environ
DEBUG = env('DEBUG')
# Raises django's ImproperlyConfigured exception if SECRET_KEY not in os.environ
SECRET_KEY = env('SECRET_KEY')
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')
# Parse database connection url strings like psql://user:pass@127.0.0.1:8458/db
DATABASES = {
# read os.environ['DATABASE_URL'] and raises ImproperlyConfigured exception if not found
'default': env.db(),
}
requirements.txt
asgiref==3.7.2
dj-database-url==2.3.0
Django==4.2.5
django-ajax-datatable==4.5.0
django-environ==0.12.0
django-heroku==0.3.1
django-on-heroku==1.1.2
gunicorn==23.0.0
packaging==24.2
psycopg2==2.9.7
psycopg2-binary==2.9.10
python-dotenv==1.0.1
sqlparse==0.4.4
typing_extensions==4.12.2
tzdata==2023.3
waitress==3.0.2
whitenoise==6.9.0
Welcome to Sushiro Bedok Mall Outlet in Singapore. Sushiro, Japan’s largest conveyor belt sushi chain, has an outlet at Bedok Mall in Singapore. This branch is located at 311 New Upper Changi Road, #B1-10, and offers various fresh and affordable sushi dishes. The restaurant operates daily from 11:00 AM to 10:00 PM, making it a convenient spot for both lunch and dinner.
During my visit to Sushiro Singapore I was impressed by the efficient service and quality of the sushi. The conveyor belt system allowed me to choose from diverse dishes, all at reasonable prices. The lively atmosphere and friendly staff made the dining experience enjoyable. https://sushiromenusg.org/sushiro-bedok-mall/
The <a href="https://kfcmenuuk.info/">KFC MENU</a> in the UK has a lot of tasty chicken meals. You can get their famous fried chicken, which is made with a special mix of spices. They sell chicken pieces, burgers like the Zinger, and meals to share like big chicken buckets. If you want something small, you can try Popcorn Chicken or wings. They also have sides like chips, corn, and coleslaw. You can get drinks and desserts too. If you don’t eat meat, there’s a vegan burger as well. There’s something for everyone to enjoy.