Error in testing application.py in cloud9 using AWS Beanstalk (dklf4jistiwtg.cloudfront.net refused to connect)

37 views Asked by At

I'm a beginner using AWS Beanstalk and now trying to test deploying a simple Flask app using the EB CLI. I have installed EB CLI on Amazon Linux, create new directory for flask and setup new virtual environment in that directory (called virt)

I have generated two files i.e. application.py as well as requirements.txt

from flask import Flask

application = Flask(__name__)

@application.route('/')
def hello_world():
    return 'Hello, AWS Elastic Beanstalk!'

if __name__ == '__main__':
    # Use port 8080 (or any port >= 1024) instead of 80 for local development
    application.run(host='0.0.0.0')

The requirements.txt:

  1. blinker==1.7.0
  2. click==8.1.7
  3. Flask==3.0.0
  4. importlib-metadata==7.0.1
  5. itsdangerous==2.1.2
  6. Jinja2==3.1.3
  7. MarkupSafe==2.1.3
  8. Werkzeug==3.0.1
  9. zipp==3.17.0

When I test it with python3 application.py, I receive this with error message: dklf4jistiwtg.cloudfront.net refused to connect.

> (virt) ec2-user:~/environment/eb-flask $ python3 application.py  *
> Serving Flask app 'application'  * Debug mode: off WARNING: This is a
> development server. Do not use it in a production deployment. Use a
> production WSGI server instead.  * Running on all addresses (0.0.0.0) 
> * Running on http://127.0.0.1:5000  * Running on http://172.31.28.1:5000

What I've tried:

  • Changing the port to 8080 in the code. Doesn't work as well

Please advise, appreciate it! I know we need to create .ebextensions file if we were to upload the zip from local, not sure if this is related.

0

There are 0 answers