首页 > 解决方案 > Can't connect to Flask API running in VM from Host Maschine

问题描述

I set up a Flask API in a Ubuntu Virtual Maschine (Virtual Box). The VM is on bridged mode. Now i want to request data from the API from the Host System (Windows) and it always tells me that the connection is refused. I tried switching to Host Only but if I try to run the VM with that it instantly crashes. I can ping the VM from Windows but can't get through to Port 5000. I think its either a Virtual Box or a Flask issue. Code of my API:

@app.route('/fnd/<text>', methods=['GET'])
def fnd(text):
    print(text)
    return jsonify(text)


if __name__ == '__main__':
    app.run(host='0.0.0.0',port=5000, Debug=False)

Browser Request

Virtual Box Settings

标签: pythonflaskvirtual-machine

解决方案


推荐阅读