Elastic Beanstalk times out when launching Python Flask webapp

0

I have a simple flask app (link to code base) that I am trying to deploy on Elastic Beanstalk. I followed this tutorial for instructions on how to deploy my website. Running eb init and eb create throw no errors but opening the site gives me a "504 Gateway Time-out" message. Within the EB console, this environment's health reads severe and says:

  • 100.0 % of the requests are erroring with HTTP 4xx. Insufficient request rate (12.0 requests/min) to determine application health.
  • ELB processes are not healthy on all instances.
  • ELB health is failing or not available for all instances. I downloaded the logs and noticed in the web.stdout.log that it starts with:
Mar  9 19:14:14 ip-172-31-14-240 web: [2023-03-09 19:14:14 +0000] [3471] [INFO] Starting gunicorn 20.1.0
Mar  9 19:14:14 ip-172-31-14-240 web: [2023-03-09 19:14:14 +0000] [3471] [INFO] Listening at: http://127.0.0.1:8000 (3471)
Mar  9 19:14:14 ip-172-31-14-240 web: [2023-03-09 19:14:14 +0000] [3471] [INFO] Using worker: gthread
Mar  9 19:14:14 ip-172-31-14-240 web: [2023-03-09 19:14:14 +0000] [3525] [INFO] Booting worker with pid: 3525
Mar  9 19:14:14 ip-172-31-14-240 web: Database Created!
Mar  9 19:14:14 ip-172-31-14-240 web: * Serving Flask app 'website'
Mar  9 19:14:14 ip-172-31-14-240 web: * Debug mode: on
Mar  9 19:14:14 ip-172-31-14-240 web: #033[31m#033[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.#033[0m
Mar  9 19:14:14 ip-172-31-14-240 web: * Running on http://127.0.0.1:5000
Mar  9 19:14:14 ip-172-31-14-240 web: #033[33mPress CTRL+C to quit#033[0m
Mar  9 19:14:14 ip-172-31-14-240 web: * Restarting with stat

Then this is followed by:

Mar  9 19:14:14 ip-172-31-14-240 web: [2023-03-09 19:14:14 +0000] [3528] [INFO] Starting gunicorn 20.1.0
Mar  9 19:14:14 ip-172-31-14-240 web: [2023-03-09 19:14:14 +0000] [3528] [ERROR] Connection in use: ('127.0.0.1', 8000)
Mar  9 19:14:14 ip-172-31-14-240 web: [2023-03-09 19:14:14 +0000] [3528] [ERROR] Retrying in 1 second.
Mar  9 19:14:15 ip-172-31-14-240 web: [2023-03-09 19:14:15 +0000] [3528] [ERROR] Connection in use: ('127.0.0.1', 8000)
Mar  9 19:14:15 ip-172-31-14-240 web: [2023-03-09 19:14:15 +0000] [3528] [ERROR] Retrying in 1 second.
Mar  9 19:14:16 ip-172-31-14-240 web: [2023-03-09 19:14:16 +0000] [3528] [ERROR] Connection in use: ('127.0.0.1', 8000)
Mar  9 19:14:16 ip-172-31-14-240 web: [2023-03-09 19:14:16 +0000] [3528] [ERROR] Retrying in 1 second.
Mar  9 19:14:17 ip-172-31-14-240 web: [2023-03-09 19:14:17 +0000] [3528] [ERROR] Connection in use: ('127.0.0.1', 8000)
Mar  9 19:14:17 ip-172-31-14-240 web: [2023-03-09 19:14:17 +0000] [3528] [ERROR] Retrying in 1 second.
Mar  9 19:14:18 ip-172-31-14-240 web: [2023-03-09 19:14:18 +0000] [3528] [ERROR] Connection in use: ('127.0.0.1', 8000)
Mar  9 19:14:18 ip-172-31-14-240 web: [2023-03-09 19:14:18 +0000] [3528] [ERROR] Retrying in 1 second.
Mar  9 19:14:19 ip-172-31-14-240 web: [2023-03-09 19:14:19 +0000] [3528] [ERROR] Can't connect to ('127.0.0.1', 8000)
Mar  9 19:14:19 ip-172-31-14-240 web: [2023-03-09 19:14:19 +0000] [3525] [INFO] Worker exiting (pid: 3525)
Mar  9 19:14:19 ip-172-31-14-240 web: [2023-03-09 19:14:19 +0000] [3531] [INFO] Booting worker with pid: 3531
Mar  9 19:14:20 ip-172-31-14-240 web: Database Created!
Mar  9 19:14:20 ip-172-31-14-240 web: * Serving Flask app 'website'
Mar  9 19:14:20 ip-172-31-14-240 web: * Debug mode: on
Mar  9 19:14:20 ip-172-31-14-240 web: #033[31m#033[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.#033[0m
Mar  9 19:14:20 ip-172-31-14-240 web: * Running on http://127.0.0.1:5000
Mar  9 19:14:20 ip-172-31-14-240 web: #033[33mPress CTRL+C to quit#033[0m
Mar  9 19:14:20 ip-172-31-14-240 web: * Restarting with stat

And those logs just repeat until the server times out. It seems like it launches successfully, since the initial logs is what I see in my console when launching the app locally. When launching locally, it also restarts once but then succeeds and runs. However, when running on EB it seems like it cannot restart because "[ERROR] Connection in use: ('127.0.0.1', 8000)". Then it just repeats this until it times out.

Has anyone encountered something similar? Does anyone have any insights into fixing this issue? It seems like I may have something configured incorrectly? Thank you in advance for any assistance!

asked a year ago55 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions