Javascript request local server not a ec2 server

Viewed 49

In ec2 instance, i build a apache server(80) and flask server (5000)

i hoped that if request to apache server index.html in local host, associated js file request to ec2 flask server(127.0.0.1:5000) to get json data

hoped

but in real, js file request to local 5000 port not a ec2 flask server

real

is any way to request ec2 flask server except open 5000 port at ec2 server??

1 Answers

Your JS is making a request to 127.0.0.1:5000 which is localhost on your system. If you want to make JS make a request to the EC2, make sure that its sending the request to the IP of the EC2 instance, and not 127.0.0.1

Related