部署Django项目至Heroku遇H14错误:无Web进程运行
Hey there, that H14 error you're hitting is one of the most common gotchas when launching a Django app on Heroku—let's get your web processes up and running again.
First, let's call out the key error from your logs that tells us exactly what's wrong:
2020-05-19T10:16:14.542057+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=whatwilldoapp.herokuapp.com request_id=d12ca631-fcbc-4240-b823-d24d2fa373d6 fwd="27.61.152.130" dyno= connect= service= status=503 bytes= protocol=https
This error means Heroku isn't running any web dynos for your app—here's how to fix it step by step:
Check for a valid Procfile:
You need aProcfilein your project root (same directory asmanage.py) that tells Heroku how to start your web server. The file should contain this line:web: gunicorn your_project_name.wsgi --log-file -Replace
your_project_namewith the name of the folder that holds yourwsgi.pyfile (it’s the same name you used when runningdjango-admin startproject).Also, make sure
gunicornis listed in yourrequirements.txt—Heroku relies on this package to serve Django apps. If it’s missing, add it, commit the change, and push to Heroku again withgit push heroku master.Scale your web dyno:
If you already have a proper Procfile but still see the error, you just need to tell Heroku to start a web process. Run this command in your terminal:heroku ps:scale web=1This spins up 1 web dyno (you can adjust the number later if you need more capacity).
Verify the process is active:
To confirm everything worked, run:heroku psYou should see a line like
web.1: up 2020/05/19 10:20:00 (~ 5m ago)—that means your web process is running.
After completing these steps, refresh your app’s homepage—it should load without the 503 error!
内容的提问来源于stack exchange,提问作者user12535249

