Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KeyError: 'DATABASE_URL'

I need help with this issue.

When I start processes locally using foreman start I get this output.

 21:59:18 web.1  |     DB_URI = os.environ['DATABASE_URL']
 21:59:18 web.1  |   File        "/Users/radhikasrinivasan/myproject/venv/bin/../lib/python2.7/UserDict.py", line 23, in   __getitem__
21:59:18 web.1  |     raise KeyError(key)
21:59:18 web.1  | KeyError: 'DATABASE_URL'
21:59:18 web.1  | exited with code 1
21:59:18 system | sending SIGTERM to all processes
SIGTERM received

In settings.py if this helps. When the app is deployed in Heroku it is in Heroku Postgres :: Orange

 DATABASES = {
          'default': {
                      'ENGINE': 'django.db.backends.sqlite3', 
                           #'ENGINE': 'django.db.backends.postgresql_psycopg2',
                       #'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
              }
}

 #Connecting with Django
     import dj_database_url
     DATABASES['default'] = dj_database_url.config(default='sqlite://db/sqlite3.db')

Thank you, Rads

like image 912
Rads Avatar asked May 06 '26 10:05

Rads


1 Answers

It means you don't have an environment variable DATABASE_URL declared, or it would be visible in os.environ dict.

EDIT

Not a Heroku expert, but maybe you should follow this:

https://devcenter.heroku.com/articles/config-vars#setting-up-config-vars-for-a-deployed-application

like image 75
tonjo Avatar answered May 08 '26 00:05

tonjo