0

I am trying to deploy a simple python app to heroku but I am getting application error while running the command "heroku open".

Below is the list of files and folders in my root directory of the application.

files_list

Inside my Procfile, I have written the below code:

      web: gunicorn script1:app

This is the first time I am trying to deploy the app to heroku. Below is the sequence of commands I am using for the same:

  1. Create 3 files in my root folder, requirements.txt, Procfile, runtime.txt.
  2. Open command prompt, navigate to root folder, run command "heroku login" - Login successful after providing the email.
  3. "heroku create myappname" - Created the app successfully.
  4. "git init" - Created the .git folder in my root path.
  5. "git add ." - Added all the files in the current directory to the git repository successfuly.
  6. "git config --global user.email "[email protected]" - Successfully authenticated.
  7. "git config --global user.name "username"
  8. "git commit -m "first commit""
  9. "heroku git:remote --app myappname"
  10. "git push heroku master" - Successfully detected and deployed the app with a message: Verifying deploy... done.
  11. "heroku open" - Whenever I run this command I get Application error.

Everything went smoothly till step 10. But, whenever I try opening the app, it gives application error in the browser.

I searched the internet and tried 2 solutions but none of them worked for me:

  1. To run the command before opening heroku - "heroku ps:scale web=1"

  2. To change the run method in the scripts file as :

     if __name__ == "__main__":
                port = int(os.environ.get("PORT", 5000))
                app.run(host="0.0.0.0", port=port)
    

I don't know what I am doing wrong, any help would be greatly appreciated.

Screenshot of error: enter image description here

Logs:

heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" status=503

enter image description here

5
  • what more is in the log? Likely the actuall error when starting the server will be visible too Commented Oct 15, 2020 at 5:28
  • I posted the screenshot of the logs. Commented Oct 15, 2020 at 5:52
  • 1. git push heroku master this pushes the local master branch to the remote master branch. Verify that you are locally also working on the master branch. 2. web: gunicorn script1:app don't use gunicorn. Use it after you verified it is working. gunicorn doesn't print out a lot of the errror messages. Instead change that to: web: python script1.py 3. No web processes running go to herokuapp.com then to your app, select resources and activate your app there. Commented Oct 15, 2020 at 7:38
  • yes, I am working on the master branch locally. I verified this through the command "git branch". I changed "web: gunicorn script1:app" to "web: python script1.py", but it doesn't seems to work. I also went to the heroku dashboard--> selected myapp --> view app. It results in the same error. Commented Oct 15, 2020 at 10:42
  • I figured out the issue. Even though the Procfile didn't show any extension in my root directory, it was saved as text document. When I opened the code in my IDE visual studio code, I saw the "Procfile.txt" was present, I renamed the file and deleted the .txt from the name. I deleted .git repository and carried out the above steps again. And I am able to successfully launch the application on heroku. Posting this answer, if it would be helpful to someone else. Commented Oct 15, 2020 at 13:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.