0

I have this ProcFile file following this guidelines for django app deployment on section Build your app and run it locally in order to test it locally you have to run this command.

web: python manage.py runserver 0.0.0.0:$PORT

Then running heroku local or heroku local web got me into this error:

CommandError: "0.0.0.0:$PORT" is not a valid port number or address:port pair.
Shift 'n Tab
  • 8,808
  • 12
  • 73
  • 117

3 Answers3

1

You must not use runserver in production. Use gunicorn as the docs and comments suggest.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Im following the guidelines in the link provided in my question, im taking the step to run the app locally using `heroku local web` command. I will not know how to deploy this app without following it first. – Shift 'n Tab Jul 12 '17 at 11:02
  • **Nothing** in that linked document mentions using runserver. It uses gunicorn throughout, and so should you. – Daniel Roseman Jul 12 '17 at 11:05
  • Please look at this https://devcenter.heroku.com/articles/deploying-python#build-your-app-and-run-it-locally it is under the Build your app and run it locally section, a suggestion for windows user – Shift 'n Tab Jul 12 '17 at 11:07
1

For local:

If you follow this official heroku tutorial and you are running it on Window platform locally, instead of $PORT, you have to use %PORT% at your Procfile.windows:

web: python manage.py runserver 0.0.0.0:%PORT%

since window does not interpret $PORT expression which only applicable in Unix shells.

If one using waitress as WSGI and wanna run it locally on Window platform, your Procfile should looks like this:

web: waitress-serve --port=%PORT% wsgi:your_app

For real online deployment:

simply include gunicorn package in requirementx.txt and your Procfile should be in this way:

web: gunicorn wsgi:your_app

If you are using waitress, you need to change back to $PORT, and set it in this way instead of fixed port number since Heroku assigns port to your app dynamically. Also, do make sure the host is set to 0.0.0.0 so your app is available externally.

IvanPy
  • 51
  • 6
0

For a django project in heroku you must have a Procfile like this:

web: gunicorn yourapp.wsgi

The filename must be Procfile, and not ProcFile

If you want to run into development you can either $ python manage.py runserver in your shell (heroku independent) or run $ heroku local with a valid production Procfile

echefede
  • 497
  • 4
  • 13
  • I mean a Procfile exactly like this. As @DanielRoseman said, you must not use runserver. And be carefull with the file name uppercase. – echefede Jul 12 '17 at 09:33
  • 1
    Oh yes, but im following the guideline to test my app locally using heroku local web commandline, it is the step necessary to learn deployment. – Shift 'n Tab Jul 12 '17 at 11:05
  • If you want to run into development you can either `$ python manage.py runserver` in your shell (heroku independent) or run `$ heroku local` with a valid production Procfile. – echefede Jul 12 '17 at 11:21