I’m running a Flask application inside a Vagrant virtual machine. The app is set to listen on all addresses (0.0.0.0), and I can access it from within the VM using curl http://localhost:5000. However, I cannot reach it from my host laptop’s web browser. I get a “This site cant be reached” error.
below is the code i used
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return "Congratulations! Flask is running successfully."
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
and when i run it, i get
vagrant@ubuntu-focal:~/smart-home-project$ python3 app.py
- Serving Flask app ‘app’
- 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://localhost:5000
- Running on http://Vm-ip:5000
Press CTRL+C to quit
i get the error when i paste http://Vm-ip:5000 on my browser
I confirmed that the Flask app is running correctly and accessible from the VM.
I tried changing the port to 8000
i tried disabling firewall on both Vm and the laptop
I was hoping that with this, i’d be able to load it on my browser but the error still persist
Luka108 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.