How to access localhost from another computer on same network? [duplicate] How to access localhost from another computer on same network? [duplicate] flask flask

How to access localhost from another computer on same network? [duplicate]


Open the port 5000 in your machine. Follow the steps:

  1. Navigate to Control Panel, System and Security and Windows Firewall.
  2. Select Advanced settings and highlight Inbound Rules in the left pane.
  3. Right click Inbound Rules and select New Rule.
  4. Add the port you need to open and click Next(5000 in your case).
  5. Add the protocol (TCP or UDP) and the port number into the next window and click Next.
  6. Select Allow the connection in the next window and hit Next.
  7. Select the network type as you see fit and click Next.
  8. Name the rule something meaningful and click Finish.

Then try to access through <your ip>:5000

sample code is as follows:

import flaskapp = flask.Flask(__name__)app.config["DEBUG"] = True@app.route('/', methods=['GET'])def home():    return "<h1>Test Data</p>"app.run(host='0.0.0.0')

and run your application through cmd as python api.py where api.py is the file name


To access a Flask app from another machine, you need the app to bind to 0.0.0.0 instead of localhost (127.0.0.1). The latter won't route to another machine.

If you're running the app via python, use run(host='0.0.0.0').

If you're running the app the flask run, add --host=0.0.0.0


Might be easier to just make it public temporarily: https://ngrok.com/

But would be even easier to do your testing locally from the same machine.