WebFaction
Community site: login faq

I set my SECRET_KEY environment variable in the console like this:

export SECRET_KEY=random_secret_key

But it seems like the Key is 'forgotten' by the system, after a few hours I would receive an error while trying to access the application in the logs that states the following.

 SECRET_KEY = get_env_setting('SECRET_KEY')
[Mon Sep 15 00:19:02 2014] [error] [client 127.0.0.1]   File "/home/user/webapps/directory/to/app", line 20, in get_env_setting
[Mon Sep 15 00:19:02 2014] [error] [client 127.0.0.1]     raise ImproperlyConfigured(error_msg)
[Mon Sep 15 00:19:02 2014] [error] [client 127.0.0.1] ImproperlyConfigured: Set the SECRET_KEY env variable

asked 15 Sep '14, 01:58

xpostudio4
128
accept rate: 100%


If this is Django you might want to check settings.py. You can also try to search for the variable with grep to see if it is set within a file,

grep SECRET_KEY -R ~
permanent link

answered 15 Sep '14, 03:27

johns
5.3k212
accept rate: 23%

Another possibility is that when you manually start the application from the console, it works because you have exported that environment variable. However, if your application ever goes down and is restarted automatically via cron, then that environment variable won't be set.

The simple solution if this is the case is to export the variable in your application's "start" script, so regardless of whether you run that script manually or whether it's called from cron, that variable will be set.

permanent link

answered 15 Sep '14, 03:59

ryans ♦♦
5.0k93160
accept rate: 43%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×906
×55
×11

question asked: 15 Sep '14, 01:58

question was seen: 1,656 times

last updated: 15 Sep '14, 03:59

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM