Application error on heroku failed to update heroku config - django

I have hosted a django project on heroku and I'm trying to update my environment variables through heroku config but, I wrote the following command
heroku config:set SECRET_KEY="djang...j*yb13jkqu-+q+l&)#b(g..."
And it shows me the following result
j*yb13jkqu-+q+l was unexpected at this time.

Try without quotes, just like that:
heroku config:set SECRET_KEY=s3cr3Tk3yj*yb13jkqu-+q+l&)#b(g

As mentioned in documentation your env variable should not include hyphen characters.

Related

Why is Procfile not recognised by Heroku?

I'm trying to deploy a flask app to heroku, but I keep on getting the error:
Scaling dynos... ! ▸ Couldn't find that process type (web).
whenever I try to run heroku ps:scale web=1.
However, when I run heroku ps:scale, it tells me that I need to Upload a Procfile to add process types.
I do have a Procfile located in my root directory, and it is capitalised and doesn't have any file extensions. I have tried deleting and recreating the Procfile, but this hasn't produced any results.
How do I get Heroku to recognise my Procfile?
Here is what I've been trying to do:
ubuntu terminal
I had to create a new git repo and heroku app, and copy the code over for it to work.

Error during deploying django app in Heroku

I am trying to deploy a Django application to Heroku. When I followed the documentation and tried the command git push heroku master, I am getting an error: failed to push some refs to 'https://git.heroku.com/sleepy-eyrie-25993.git'. I searched online and tried to use git pull. But it didn't work. I also tried using git push -f heroku master, but still getting the same error. Is there any other way to do it? I followed this doc
https://devcenter.heroku.com/articles/python-support.
Tried using the heroku dashboard, but it is giving the same error
Building on the Heroku-18 stack ! No default language could be detected for this app. HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically. See https://devcenter.heroku.com/articles/buildpacks ! Push failed
You can also deploy from your application dashboard on Heroku
Heroku deployment requires requirements.txt in the root of the repository.
Also, to run a Django app - it requires file Procfile
Sample content:
web: gunicorn your_app_name.wsgi:application --log-file -
You can also try to specify buildpack manually by executing:
heroku buildpacks:set heroku/python
Then if there are additional errors starting - they will be more specific
Also settings.py of your Django application should contain the following:
import django_heroku
django_heroku.settings(locals())
For more details, please refer Here

Heroku not running collectstatic with Django

So I have a Django app, I've turned off DISABLE_COLLECTSTATIC but there's no mention of collect static happening.
Some research showed that Heroku would fail silently if collect static fails, but would write out during the build log when collect static succeeds. I did heroku run python manage.py collectstatic and it ran correctly. No errors.
However, collect static still isn't running on build
The catch turned out to be that to disable a config var, one must use:
heroku config:unset DISABLE_COLLECTSTATIC
I was using the wrong command since heroku config displayed initally DISABLE_COLLECTSTATIC: 1 I assumed heroku config:set DISABLE_COLLECTSTATIC=0 would turn off the config var. Since nothing else seemed off, this assumption became the next likely suspect. Following Heroku docs about handling config, I ran all of
heroku config:set DISABLE_COLLECTSTATIC=false
heroku config:set DISABLE_COLLECTSTATIC=False which don't work as desired.

How to overcome 'Coudn't find that formation' error when adding web dynos to Heroku django app?

I'm trying to get deploy a simple django app, and have successfully pushed my git repository to Heroku. However, when I attempt to run:
heroku ps:scale web=1
I get the following error
Scaling dynos... failed
! Couldn't find that formation.
Any thoughts as to what the problem might be? The contents of the Procfile (below) are correct to the best of my knowledge.
web: gunicorn my_app_name.wsgi
To state the obvious: another way to encounter this issue is if you're working on a new app, and you try running heroku ps:scale web=1 before you've actually done a git push heroku master. There is no Procfile on the Heroku server in that case, because there aren't any files at all. :D
Ensure that your Procfile has no extension.
To create a file with no extension on Windows, you can use the command notepad Procfile. from the command line.
To add yet another reason this can happen, my Procfile contained
web:gunicorn
but it should be:
web: gunicorn
As far as I can tell from all of these answers, if you run into this problem, it is very likely related to Procfile.
for those interested, I had the same problem to add a worker. to do so you need to add this line to your procfile : worker: python worker.py
For others experiencing this same issue, make sure Procfile is not ignored in git.
Delete your Procfile. Then git status. If don't see anything mentioning Procfile, you need to find remove the entry from local or global .gitignore.
I faced a similar issue while working on windows(haven't tested on other operating systems)and this worked fine for me.
Initially, I have created a file name procfile and pushed it to heroku. But, heroku expects the Procfile declaration. It is case sensitive. Hence, we should be careful while typing the filename also.
Even after changing the name to Procfile git didnt notice changes(maybe git is case-insensitive just like windows). Hence, I had to delete the file completly and had to create a new one with Procfile as the name of the file.
I had the same problem because I missed git add and git commit the file named Procfile .
You should try to use the command git status and review whether the Procfile is included.
When pushing to Heroku you must come up with something like shown in the Picture. If not your procfile has an Error.
The Procfile looks like this for my Flask app
web: gunicorn app:app
In my php project I can use
$ heroku ps:scale web=1
at the heroku directory "php-getting-started" (https://devcenter.heroku.com/articles/getting-started-with-php#prepare-the-app).
So I'm try to do this in my original application, so I tried to do again in Heroku Repository and it's work.
(sorry about the english, hehe)
I got the same problme,
1) I also configured ProcFile
but the problem still available
So used this
Remove the existing buildpacks with heroku buildpacks:clear and add them again in the right order using the heroku buildpacks:add with the --index option, making sure that the language buildpack is the last in the list
git commit --allow-empty -m "Adjust buildpacks on Heroku"
git push heroku master
Problem solved
I had a similar problem and tried the following:
Made sure Procfile does not have any extension
Procfile is spelled exactly as 'Procfile'
At the end of the day just realized that my Procfile was in my app directory. It should be on the root/project directory.

Issue with Heroku, configuration variables and django using S3

I'm having a very strange issue.
I have my django project running in Heroku using S3 to store my static assets.
I wanted to use the Heroku enviroment variables by setting them as follows:
heroku config:add AWS_S3_TOKEN=my_s3_token
heroku config:add AWS_S3_SECRET=my_s3_secret
And using them with python's os module:
import os
token = os.getenv('AWS_S3_TOKEN')
secret = os.getenv('AWS_S3_SECRET')
But heroku keeps throwing me the following error:
NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV1Handler'] Check your credentials
So, I ended up writing those parameters in my settings.py file and it works fine
Why is this happening?
If I run
heroku config
I can see all my seted variables and if i do
heroku run python manage.py shell
and then
import os
print os.getenv('AWS_S3_TOKEN')
For example, it prints the variable's value.
any clue on this???
Thank you in advance
I'm not familiar with python or Django, but I'm curious.
If you try your authentication with blank strings, do you get the same error?
If so, then I suspect it's about when you're doing this authentication dance. When are you doing it? At compile time, or at runtime? (If at compile time, look at this)
The app's environment variables aren't usually available while Heroku is compiling the slug and setting up the application, they're only available once the app is running. For a Django app, Heroku will run collectstatic as part of slug compilation, which is probably why you're seeing this error.
You can make the environment variables available during compilation by enabling a Heroku Labs feature:
heroku labs:enable user-env-compile
There's more information in this Heroku dev centre article: https://devcenter.heroku.com/articles/labs-user-env-compile