{"id":1118,"hash":"39eacf1c184508e8adff1a57a347395de60f7b12c654d1207908991be15f9f0c","pattern":"Error: gunicorn: Failed to find application object &#39;app&#39; in &#39;app&#39;","full_message":"Here's my code:\n\napp.py\n\nfrom flask_graphql import GraphQLView\nfrom app.infrastructure.graphql import schema\nfrom app.infrastructure.api_resource import app\n\napp.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))\n\nif __name__ == '__main__':\n    app.run(debug=True)\n\napi_resource.py\n\nimport app.infrastructure.repository as repository\nfrom flask import request, url_for\nfrom flask_restplus import Api, Resource, fields\nfrom sqlalchemy_pagination import paginate\nfrom sqlalchemy_fulltext import FullTextSearch\n\napp = repository.app\napi = Api(app, version='0.1', title='xxxxx',\n          description='xxxxx')\n...\n\nrepository.py\n\nfrom flask import Flask\nfrom flask_sqlalchemy import SQLAlchemy\nfrom app.domain.model import Base\n\nconnection_string = 'xxxxxx'\n\napp = Flask(__name__)\napp.config['SQLALCHEMY_DATABASE_URI'] = connection_string\napp.config['SQLALCHEMY_ECHO'] = True\ndb = SQLAlchemy(app, metadata=Base.metadata)\n\nHowever, when i execute the gunicorn command \"gunicorn app: app\" i get this error:\n\nFailed to find application object 'app' in 'app'\n\nI'm using pipenv whith pipenv shell on ubuntu 16.04, but i've also tried on a docker container and got the same error.\nhere's my pip file:\n\n[[source]]\nurl = \"https://pypi.python.org/simple\"\nverify_ssl = true\nname = \"pypi\"\n\n[dev-packages]\n\n[packages]\nflask-graphql = \"*\"\nflask-sqlalchemy = \"*\"\nsqlalchemy-fulltext-search = \"*\"\ngraphene-sqlalchemy = \">=2.0\"\nflask-marshmallow = \"*\"\nsqlalchemy-pagination = \"*\"\nflask-restplus = \"*\"\nrequests = \"*\"\nmysqlclient = \"*\"\ngunicorn = \"*\"\n\n[requires]\npython_version = \"3.6\"\n\nWhat am i doing wrong?","ecosystem":"pypi","package_name":"python-3.x","package_version":null,"solution":"You have a folder called app (as by the import lines in your file) and a app.py file. \n\nGunicorn will try to find the app WSGI variable inside the app module, which in your case is identified as app/__init__.py\n\nYou need to rename your folder or your app.py file to avoid this conflict.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/50157243/error-gunicorn-failed-to-find-application-object-app-in-app","votes":16,"created_at":"2026-04-19T04:52:22.557832+00:00","updated_at":"2026-04-19T04:52:22.557832+00:00"}