Bash: gunicorn: app:app with flask app

i am gettting the below error even after adding gunicorn to the requirments.txt.

Starting service with ‘gunicorn app:app’
Aug 1 12:48:12 PM Traceback (most recent call last):
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/bin/gunicorn”, line 8, in
Aug 1 12:48:12 PM sys.exit(run())
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py”, line 67, in run
Aug 1 12:48:12 PM WSGIApplication(“%(prog)s [OPTIONS] [APP_MODULE]”).run()
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py”, line 236, in run
Aug 1 12:48:12 PM super().run()
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py”, line 72, in run
Aug 1 12:48:12 PM Arbiter(self).run()
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/arbiter.py”, line 58, in init
Aug 1 12:48:12 PM self.setup(app)
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/arbiter.py”, line 118, in setup
Aug 1 12:48:12 PM self.app.wsgi()
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py”, line 67, in wsgi
Aug 1 12:48:12 PM self.callable = self.load()
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py”, line 58, in load
Aug 1 12:48:12 PM return self.load_wsgiapp()
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py”, line 48, in load_wsgiapp
Aug 1 12:48:12 PM return util.import_app(self.app_uri)
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/util.py”, line 371, in import_app
Aug 1 12:48:12 PM mod = importlib.import_module(module)
Aug 1 12:48:12 PM File “/usr/local/lib/python3.7/importlib/init.py”, line 127, in import_module
Aug 1 12:48:12 PM return _bootstrap._gcd_import(name[level:], package, level)
Aug 1 12:48:12 PM File “”, line 1006, in _gcd_import
Aug 1 12:48:12 PM File “”, line 983, in _find_and_load
Aug 1 12:48:12 PM File “”, line 967, in _find_and_load_unlocked
Aug 1 12:48:12 PM File “”, line 677, in _load_unlocked
Aug 1 12:48:12 PM File “”, line 728, in exec_module
Aug 1 12:48:12 PM File “”, line 219, in _call_with_frames_removed
Aug 1 12:48:12 PM File “/opt/render/project/src/app.py”, line 38, in
Aug 1 12:48:12 PM engine = create_engine(connect)
Aug 1 12:48:12 PM File “”, line 2, in create_engine
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/sqlalchemy/util/deprecations.py”, line 281, in warned
Aug 1 12:48:12 PM return fn(*args, **kwargs) # type: ignore[no-any-return]
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/sqlalchemy/engine/create.py”, line 548, in create_engine
Aug 1 12:48:12 PM u = _url.make_url(url)
Aug 1 12:48:12 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/sqlalchemy/engine/url.py”, line 843, in make_url
Aug 1 12:48:12 PM f"Expected string or URL object, got {name_or_url!r}"
Aug 1 12:48:12 PM sqlalchemy.exc.ArgumentError: Expected string or URL object, got None
Aug 1 12:48:14 PM ==> Using Node version 14.17.0 (default)
Aug 1 12:48:14 PM ==> Docs on specifying a Node version: Specifying a Node Version | Render
Aug 1 12:48:16 PM ==> Starting service with ‘gunicorn app:app’
Aug 1 12:48:18 PM Traceback (most recent call last):
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/bin/gunicorn”, line 8, in
Aug 1 12:48:18 PM sys.exit(run())
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py”, line 67, in run
Aug 1 12:48:18 PM WSGIApplication(“%(prog)s [OPTIONS] [APP_MODULE]”).run()
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py”, line 236, in run
Aug 1 12:48:18 PM super().run()
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py”, line 72, in run
Aug 1 12:48:18 PM Arbiter(self).run()
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/arbiter.py”, line 58, in init
Aug 1 12:48:18 PM self.setup(app)
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/arbiter.py”, line 118, in setup
Aug 1 12:48:18 PM self.app.wsgi()
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py”, line 67, in wsgi
Aug 1 12:48:18 PM self.callable = self.load()
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py”, line 58, in load
Aug 1 12:48:18 PM return self.load_wsgiapp()
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py”, line 48, in load_wsgiapp
Aug 1 12:48:18 PM return util.import_app(self.app_uri)
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/util.py”, line 371, in import_app
Aug 1 12:48:18 PM mod = importlib.import_module(module)
Aug 1 12:48:18 PM File “/usr/local/lib/python3.7/importlib/init.py”, line 127, in import_module
Aug 1 12:48:18 PM return _bootstrap._gcd_import(name[level:], package, level)
Aug 1 12:48:18 PM File “”, line 1006, in _gcd_import
Aug 1 12:48:18 PM File “”, line 983, in _find_and_load
Aug 1 12:48:18 PM File “”, line 967, in _find_and_load_unlocked
Aug 1 12:48:18 PM File “”, line 677, in _load_unlocked
Aug 1 12:48:18 PM File “”, line 728, in exec_module
Aug 1 12:48:18 PM File “”, line 219, in _call_with_frames_removed
Aug 1 12:48:18 PM File “/opt/render/project/src/app.py”, line 38, in
Aug 1 12:48:18 PM engine = create_engine(connect)
Aug 1 12:48:18 PM File “”, line 2, in create_engine
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/sqlalchemy/util/deprecations.py”, line 281, in warned
Aug 1 12:48:18 PM return fn(*args, **kwargs) # type: ignore[no-any-return]
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/sqlalchemy/engine/create.py”, line 548, in create_engine
Aug 1 12:48:18 PM u = _url.make_url(url)
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/sqlalchemy/engine/url.py”, line 843, in make_url
Aug 1 12:48:18 PM f"Expected string or URL object, got {name_or_url!r}"
Aug 1 12:48:18 PM sqlalchemy.exc.ArgumentError: Expected string or URL object, got None

Your app.py file on line 38 is calling SQLAlchemy functions with empty, or invalid data.

it actually not empty though, it contain “connect” which is the variable that stores the database uri. pls check again.

Aug 1 12:48:18 PM File “/opt/render/project/src/app.py”, line 38, in
[…]
Aug 1 12:48:18 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/sqlalchemy/engine/url.py”, line 843, in make_url
Aug 1 12:48:18 PM f"Expected string or URL object, got {name_or_url!r}"
Aug 1 12:48:18 PM sqlalchemy.exc.ArgumentError: Expected string or URL object, got None

Top line is referencing where your code called an external function, bottom line is SQLAlchemy erroring because of how it was called by your code. “got None” means that the connection string was blank. If your code’s connection uses a variable, that variable is empty.

its resolved, i have included it in the environment variables

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.