34👍
Benjamin Manns’ solution worked for me, though I needed one additional step as well.
According to this, after the Procfile
solution has been pushed, run the following:
heroku ps:scale web=1
website should load correctly now.
for more help pushing to a heroku git repo, see this
- Check for request.GET variable in the template
- Is there a way to generate pdf containing non-ascii symbols with pisa from django template?
- Why does Django use tuples for settings and not lists?
- Django Views: When is request.data a dict vs a QueryDict?
9👍
Have you gone through the Heroku guide for setting up a Django application? What does your Procfile look like?
Your project should have a file named Procfile
that should have contents similar to
web: gunicorn hellodjango.wsgi
- Django – Import views from separate apps
- What does "Directory indexes are not allowed here." mean in a Django error?
- Django prefetch_related's Prefetch, order_by?
- Django – inlineformset_factory with more than one ForeignKey
4👍
Your Procfile must look like this (for python):
web: python myApp.py runserver 0.0.0.0:$PORT
- Django ForeignKey limit_choices_to a different ForeignKey id
- ERROR: Invalid HTTP_HOST header: '/webapps/../gunicorn.sock'
- Passing an object created with SubFactory and LazyAttribute to a RelatedFactory in factory_boy
- Building a Mobile App With jQuery Mobile, Django, and Phonegap
4👍
If you are in python/django
heroku logs --tail
if you are unable to find the bug and fix then try doing,
First Run to see whether its working in herokus local
heroku local web
Mine was to specify the path of django wsgi.py file in Procfile
see their example https://github.com/heroku/python-getting-started
The Procfile will look similar to this
web: gunicorn projectname.wsgi --log-file -
You may have to install gunicorn if not installed and add it to requirements.txt
Then Git add and commit, after that push to heroku
git push heroku master
Then scale your app
heroku ps:scale web=1
- Django queryset order_by dates near today
- How can I disable a model field in a django form
- Django 'resolve' : get the url name instead of the view_function
- ForeignKey to a model that is defined after/below the current model
1👍
I did the following steps to make it work.
1) I had to move my Procfile to the outermost folder.
2) Then I had to change my Procfile to
web: gunicorn projectname.projectname.wsgi
3) Also in my wsgi file I had to change my settings path to
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projectname.projectname.settings')
4) In my settings.py file I had to change my ROOT_URLCONF
ROOT_URLCONF = 'projectname.projectname.urls'
5) In urls.py I had to change my path to
from projectname.applicationname import urls as app_urls
urlpatterns = [
path('admin/', admin.site.urls),
path('', include(app_urls)),
]
6) Finally I did
git push heroku master
heroku ps:scale web=1
After making all these changes heroku worked like a charm. But it doesn’t work locally on windows because I read somewhere windows doesn’t have gunicorn.
When I tried python projectname/manage.py runserver
locally it said
ModuleNotFoundError: No module named 'projectname.projectname'
So for running it locally I’ve to revert all the steps above 😛
- How show personalized error with get_object_or_404
- "The path python3 (from –python=python3) does not exist" error
0👍
in my case it was dynos configuration error,i meant to say that if u re not premium member see whether dynos available for your app from heroku dashbord. this u can check by clicking on metrics,if you don’t have one estimate it.
run command
$ heroku ps:scale web=1
push your code in master.
0👍
I was getting application error
I checked heroku logs –tail , in desc="No web processes running"
Mostly this occur due to Procfile, so inside Procfile I forgot to give space after "web:"
web: gunicorn hellodjango.wsgi --log-file -
so check your Procfile{this file is to be created in root folder just inside project folder}
- How do you create a Django HttpRequest object with the META fields populated?
- Google App Engine Application Extremely slow
- SQL injection hacks and django
- Does changing a django models related_name attribute require a south migration?
0👍
Though it is already said but please do a check if the Procfile
, runtime.txt
and requirements.txt
are in the outermost folder. (These files will be placed in the location of manage.py
)
- Django, Security and Settings
- Method in Django to display all attributes' values belonging to a created object?
0👍
My case was a little different. I had settled up everything and deployed my app on Heroku. I have deployed 3 4 python apps on Heroku previously. had Procfile and requirements.txt in root folder.
This time, I tried almost the whole every guide and StackOverflow answers but found nothing. Then just added a space after web:
and gunicorn
and it worked perfectly.
previously I was using web:gunicorn wsgi:app
I just changed that to web: gunicorn wsgi:app
and It worked like a charm
0👍
Make sure your dynos is running otherwise you will get this above error also.
and then you have to manually start dynos on heroku, while heroku automatically start that for you but some time you have to do run manually on heroku.
Click on a Configure dynos button ==> toggle the dynos button and your dynos will start.
0👍
Check your dyno’s configuration in the Heroku dashboard. It might be the wrong app name before the wsgi module. I had an old project’s app name instead of the one I tried to use:
web: gunicorn old_project_app.wsgi
Correct your Procfile and push it to Heroku. You might need to delete and recreate the file. It should then be like this in the dyno config:
web: gunicorn new_project_app.wsgi
- How to ensure task execution order per user using Celery, RabbitMQ and Django?
- Using Django's built in web server in a production environment
- How to display "This many months ago" in Django using Humanize?
-1👍
Make sure the spelling of the Procfile. Its supposed to be "Procfile" and not "procfile"