Deploying my first Django app to Heroku: Error message 'h12' status '503'

511 views Asked by At

I'm working on my first app, and I've avoided having to ask any questions so far, but here we are at deployment.

Here is my code: (Note: The majority of the program is in '/starWarsMeals/djangoStarWarsMeals/appStarWarsMeals/utils.py' and not 'models.py'. I didn't feel a database was my best choice for this app, as the 'swapi' API I am pulling data from may change. I figured it would be best to cache the results of the API vs. updating a database periodically.)

https://github.com/RyanLegits/starWarsMeals

I am trying to deploy my Django app to Heroku, but I get the following 'h12' error code:

https://textuploader.com/16beh

My suspicion is that the API calls at the beginning of the script in 'utils.py' are taking too long and causing Heroku to time out. However, I'd like a professional opinion before trying to refactor my code. Also, the last thing I changed in the app was setting the environment variables if that is helpful.

I tried deploying to Python Anywhere just to see if I could find anymore information. I got the 'Something went wrong' page and related error log:

https://textuploader.com/16bez

Notes:

I did make sure to change 'ALLOWED_HOSTS' in 'settings.py' for each attempted deploy. I tried setting it to 'localhost' for both Heroku and Python anywhere. After Heroku told me to change it to my Heroku app url, I did, and it seemed like the app would run, but that's when I received the 'h12' error code.

I understand I went crazy with camel case. I will be fixing that, as well as updating the code later. I'm just trying to get something online for now.

I have researched this error code, but many of this is over my head, as I jumped headfirst into this app.

I am using: Django 3.0.3 Python 3.7 Everything in '/starWarsMeals/djangoStarWarsMeals/requirements.txt' (inside a virtual environment)

Any other code critiques are welcome!

Thank you!

1

There are 1 answers

9
AzyCrw4282 On

It's obvious that you have a long-running process that is taking more than 30 seconds (Heroku's limit) to return any data to the client.

2020-03-10 03:57:48,346: File "/home/dreadPrivate/.virtualenvs/myenv/lib/python3.7/site-packages/django/conf/init.py", line 63, in _setup 2020-03-10 03:57:48,346: self._wrapped = Settings(settings_module) 2020-03-10 03:57:48,346: 2020-03-10 03:57:48,347: File "/home/dreadPrivate/.virtualenvs/myenv/lib/python3.7/site-packages/django/conf/init.py", line 161, in init 2020-03-10 03:57:48,347: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")

From your error logs, I noted that you don't have the secret key set. Have you set them in your environment variables or in settings.py, given that you also mentioned this above?

Also, the last thing I changed in the app was setting the environment variables if that is helpful.