I searched for this issue but noticed it is people running a flask script inside a docker container, but not a flask script on their local machine and trying to curl it from within their docker container.
I have a simple flask script and it just says hello, but when i use curl 127.0.0.1:5000, i get a connection refused. It works if i do 192.168.0.15:5000, but that isn't what i want. I am using a mac os.
I tried adding "0.0.0.0" to the flask script instead of "127.0.0.1" but no luck.
This is my flask script:
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.route('/post',methods = ['POST'])
def post():
for key in request.form:
print ('form parameter: '+key + " form value: "+request.form[key])
return "hello"
if __name__ == '__main__':
app.run(host="0.0.0.0",port="5000")
When i open docker tomcat terminal and try to curl localhost:5000, connection refused. However, i can curl the ip the web server is running on, but i want to be able to curl localhost or 127.0.0.1. Thanks a lot.