I wrote this small piece of code:
from flask import Flask
from flask_restful import Resource, Api
import subprocess
app = Flask(__name__)
api = Api(app)
class SlackReport(Resource):
def get(self):
subprocess.Popen(['python', 'ingestion_ice3_check.py'])
return 'Request submitted'
api.add_resource(SlackReport, '/slackReport')
if __name__ == '__main__':
app.run(debug=True)
If I execute:
curl --ipv4 http://127.0.0.1:5000/slackReport
the server sends the response but if I execute the same command from another machine in the same LAN I receive a 'connection refused' message
$ curl -X GET http://10.113.12.20:5000/slackReport
curl: (7) Failed to connect to 10.113.12.20 port 5000: Connection refused
If I request the resource from localhost I can see the request from the debug console of the server
127.0.0.1 - - [28/Sep/2017 18:15:02] "GET /slackReport HTTP/1.1" 200 -
However if I request the same resource from a remote machine I can see the packet on the port but the flask server doesn't receive anything.
$ sudo tcpdump -i ens192 port 5000
18:17:53.132514 IP 10.113.12.25.37096 > tl020dash.commplex-main: Flags [S], seq 3147843104, win 14600, options [mss 1460,sackOK,TS val 822032144 ecr 0,nop,wscale 7], length 0
This is the output of netstat command
sudo netstat -tnlp | grep :5000
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 21872/python