0

I am doing experiments with requests trough proxy for web-scraping project. In order to test requests headers and content i've build a simple flask server like this:

from flask import Flask
from flask import request

app = Flask(__name__)


@app.route("/")
def index():
    ret_str = f'<- {request} ->\n' \
              f'<----- HEADERS ----->\n' \
              f'{request.headers}\n' \
              f'<----- DATA ----->\n' \
              f'{request.data}\n'
    print(ret_str)
    return ret_str

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

Which is run perfectly fine if access through localhost by 127.0.0.1:5000 (with app.run()) and through local network by requesting the local address 10.214.14.222:5000 (which is displayed by ipconfig).

But if i try to access it through my 4G connection or through proxy, request fails. According to https://ipchecker.io/, my outside ip is, let's say 216.94.151.186, but requesting my page using 216.94.151.186:5000 gives 'page not found'.

How to access the test server from outside the local network? Can anyone please help?

SOLUTION: Set up port forwarding on router and make computer that run flask server IP-address static on router.

2 Answers2

2

What you'll need to do is make your specified port available on your router. This is done with port forwarding. The location of this tab can switch depending on your router provider but once this is done you can just visit This link which shows your public IP. Then you can just visit: 000.00.000.00:5000 <-- Replace zero's with public IP.

1

Make sure that port 5000 is opened in your router.

If you have access to linux, you can use nmap to check which ports are open or go to https://portchecker.co/ and check to see if port 5000 is open.

Cerberus
  • 11
  • 1
  • Thanks mate, as I found, port 5000 is closed. But since it is a company network, can't change settings. But I will try it at home tonight. Thanks <3 – Recently_Created_User Feb 14 '22 at 09:56
  • hay mate! Did as you adviced, didn't help much, but after I've did some reading the advice is correct. However the problem is with my ISP. Will try to speak with them later tonight. – Recently_Created_User Feb 15 '22 at 14:16