[PYTHON] A story about a 503 error on Heroku open

This is the first post. Even if it is too long, I will get tired, so I write it in rough sentences. Please note that it may be difficult to read. This article is based on the article here .

environment

WSL2(Ubuntu-20.04 LTS) Docker Heroku Line-bot-sdk=1.18.0 Flask=1.1.2

Deploy to Heroku

As a premise

--Registration of line developers --Install Flask and line-bot-sdk --Register with Heroku --Application registration --Environment variable settings --webhook settings --Creating a configuration file

I would like to proceed as if it is over.

Reflect and deploy changes

# git add .
# git commit -am "make it better"
# git push heroku main

Confirm deployment

 # heroku open
  ▸    Error opening web browser.
  ▸    Error: Exited with code 3
  ▸

▸ Manually visit https: // your application name.herokuapp.com/ in your browser.

When I opened "https: // your application name.herokuapp.com/" in chrome, an application error occurred on the screen below.

Try heroku logs --tail! It is said that it will be confirmed.

# heroku logs --tail

2020-12-22T11:49:11.712077+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET 

path = "/" host = your application name.herokuapp.com ... 2020-12-22T11:49:12.443226+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET p ath = "/ favicon.ico" host = your application name.herokuapp.com ...

Code = H14, status = 503, so consider countermeasures. I searched online and found the following method.

Method 1

 # heroku ps:scale web=1

Method 2

Restart Heroku

 # heroku restart --app application_name
 # heroku stack:set container

There was a method such as, but it failed. After that, the result of various investigations.

 # cd `your-app-dir`
 echo "web: $(basename `pwd`)" > Procfile

As a result of doing, the error statement changed. Apparently, it was a misspelling of "Procfile" as "Profile": sweat_smile :. The error statement after changing the Procfile is as follows.

2020-12-22T12: 38: 17.494371 + 00: 00 heroku [router]: at = error code = H10 desc = "App crashed" method = GET path = "/" host = Anna Application name.herokuapp.com ... 2020-12-22T12: 38: 18.016959 + 00: 00 heroku [router]: at = error code = H10 desc = "App crashed" method = GET path = "/" host = Ah Your application name.herokuapp.com ... 2020-12-22T12:38:18.602766+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path = "/ favicon.ico" host = your application name.herokuapp.com ...

Since Code = H10, status = 503, I tried methods 1 and 2 again, but failed. Trial and error for several hours ... When I was looking at main.py, the cause was found.

The cause was a misspelling in an environment variable: joy :. 「SECRET」→「SELECT」

Wrong code:

$ heroku config: set YOUR_CHANNEL_SELECT = "Channel Secret string" --app Your application name

Correct code:

$ heroku config: set YOUR_CHANNEL_SECRET = "Channel Secret string" --app Your application name

It turned out that the environment variable was wrong, so I corrected the relevant part of the code in main.py to "SECRET" and From Heroku.com The problem was solved by manually resetting the environment variables in Applications-> Settings-> Config Vars.

スクリーンショット (322).png

Safely, "Hello World" was displayed on the browser.

References

https://qiita.com/shimajiri/items/cf7ccf69d184fdb2fb26 https://qiita.com/yagi_eng/items/9308b680e6ee41ab1d6d

Recommended Posts

A story about a 503 error on Heroku open
A story about running Python on PHP on Heroku
A story about displaying article-linked ads on Jubatus
A story about deploying a Twitter-linked app created using Flask + gunicorn on Heroku
A story about a Linux beginner putting Linux on a Windows tablet
A story about installing matplotlib using pip with an error
A story about a GCP beginner building a Minecraft server on GCE
A refreshing story about Python's Slice
A sloppy story about Python's Slice
A story about using Python's reduce
Cause a bus error on x86
A story about a build error in a shared library that references libusb
A story about putting Chrome OS (not Chromium) on surface GO
A story about wanting to think about garbled characters on GAE / P
A story about machine learning with Kyasuket
A story about trying to connect to MySQL using Heroku and giving up
A addictive story when using tensorflow on Android
A story about trying to install uwsgi on an EC2 instance and failing
A story about simple machine learning using TensorFlow
Open a ZIP created on Windows in Linux
Redis on Heroku
A story about Go's global variables and scope
shimehari on heroku
A story about implementing a login screen with django
A memorandum for touching python Flask on heroku
A story about modifying Python and adding functions
A story about data analysis by machine learning
A story stuck with Memory Error and No space left on device on AWS EC2
A story about an error when loading a TensorFlow model created with Google Colab locally
A story about making 3D space recognition with Python
A story about using Resona's software token with 1Password
A story about predicting exchange rates with Deep Learning
A story about migrating entire Linux disk via SSH
About Go error handling * This is a rough article.
A story about making Hanon-like sheet music with Python
A story about kindergartens, nursery schools, and children's gardens
A story about reflecting Discord activity in Slack Status
A story about struggling to loop 3 million ID data
A story about how theano was moved with TSUBAME 2.0
A story about changing the master name of BlueZ
Miscellaneous notes about deploying the django app on Heroku
A story about a Linux beginner passing LPIC101 in a week
A swampy story when using firebase on AWS lamda
A story about stumbling through PATH after installing anaconda
About tweepy error handling
A memorandum about matplotlib
I'm having trouble getting "ERROR: cannot execute ALTER TABLE in a read-only transaction" on heroku
A memorandum about Nan.
A note about __call__
A note about subprocess
A story about trying to use cron on a Raspberry Pi and getting stuck in space
A note about mprotect (2)
I thought about a Python beginner's course on blockchain games
[Linux] A story about mounting a NAS through a firewall using NFS
A story about creating a UNIX / Linux compatible OS from scratch
A story about how to specify a relative path in python.
A story about competing with a friend in Othello AI Preparation
I get [Error 2055] when trying to connect to MySQL on Heroku
Set up a Google Cloud service account key on heroku
(Failure) Deploy a web app made with Flask on heroku
A little deeper story about blockchain, ticking the digital world