You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Heroku部署Flask项目报错:gunicorn无法识别参数app:app

Fixing "gunicorn: error: unrecognized arguments: app:app" on Heroku

Got it, let's work through this Gunicorn error you're hitting on Heroku. I've dealt with this exact issue a few times, so here are the most common fixes to try:

  • Double-check your Flask app entry details
    First, confirm two key things:

    1. Is your main Flask file named app.py? If your entry file is something else (like main.py or wsgi.py), you need to update the Procfile to match. For example, if your file is main.py, the Procfile should be web: gunicorn main:app.
    2. Does your Flask instance actually have the name app? Check your code—if you defined it as application = Flask(__name__) instead of app = Flask(__name__), your Procfile needs to be web: gunicorn app:application (format is filename:instance_name).
  • Verify Gunicorn is properly specified in requirements.txt
    Heroku relies on your requirements.txt to install dependencies. Make sure you've added Gunicorn to this file—add a line like gunicorn==20.1.0 (use a stable recent version) to avoid version mismatches. If you only installed it locally but didn't list it here, Heroku might be using an incompatible version that doesn't recognize the file:instance syntax.

  • Check your project structure and working directory
    If your app.py is inside a subfolder (like src/app.py), you need to adjust the Procfile path using dots instead of slashes: web: gunicorn src.app:app. Also, test the command locally first—run gunicorn app:app from your project root. If it fails locally, fix that before redeploying to Heroku.

  • Ensure your Procfile is formatted correctly
    Small typos here can cause big issues:

    • The file must be named exactly Procfile (capital P, no .txt extension)
    • It needs to live in your project's root directory, not a subfolder
    • No extra spaces or line breaks in the line web: gunicorn app:app

Test each of these steps one by one, and you should get past that error.

内容的提问来源于stack exchange,提问作者Engramar Bollas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:50:20