To address the question itself, the log indicates that your Flask application is listening on the IP 127.0.0.1 (localhost):
Running on https://127.0.0.1:3030/
This way Flask will only accept connections made to this address only (127.0.0.1). Instead, you need to start Flask telling it to listen for new connection on the public IP of your server. Like this:
flask run --host=PUBLIC_IP
or, alternatively, simply listening on all IPs:
flask run --host=0.0.0.0
(where 0.0.0.0
means "all IPs available to the operating system")
See also: https://flask.palletsprojects.com/en/1.1.x/quickstart/#public-server
Flask in production
Based on the original log from the question, it appears that there is a couple of other matters that are better to be addressed before going to production. Making a server public (as per above) while ignoring these items is dangerous from a security perspective and the danger is very real. Specifically with a registered DNS, which, besides its original purpose, also acts as an advertisement for every bot out there. As the subject in itself is quite big, only major items are outlined below:
Minimal:
Disable debug. Debugger allows remote code execution and serving "public" requests by a server with a debugger enabled is a big (huge) and very real security risk. See more about debug mode in Flask.
Generate and configure a server secret. Server secret is used, for example, to sign cookies, and it needs to be unique and, well, secret. See more about server secret.
Run a WSGI server instead of a Flask development server. When you start flask run
it runs a development server which is not designed for performance or reliability. However, applications implemented with Flask framework are valid WSGI applications, and can be served by any WSGI server software, such as uWSGI for example, or gunicorn, or waitress to name a few popular ones.
Normally also:
Run Flask server behind a reverse proxy, such as nginx for example. Reverse proxy may handle a bunch of functionality, such as serving static files, provide SSL termination (https), compression, caching, etc. in a very effective (in terms of performance) manner.
Consider persisting Flask application log. In case of any troubles you might want to understand what happened. By default Flask logs are directed to the stdout and won't be persisted should the server restart. (So all past logs will be lost).
The check-list of going to production certainly goes on and on, but I think above are the items that must be addressed in order to avoid a serious trouble.
Alternatively you may consider other options that take care of most of the typical "production" configuration. Options below may be a good idea because this way you will rely on existing and well-supported configuration made by experts. For example:
- Deploy to a managed service, such as AWS ElasticBeanstalk, Heroku, etc. etc.
- If you prefer having more control over the environment, consider packaging the application into a Docker image based on some well-supported base image with some of the above items pre-configured (for instance: https://github.com/tiangolo/uwsgi-nginx-flask-docker)
See also: