flaskwindows-subsystem-for-linuxfirewall

Enable public internet traffic to Flask app running in WSL


I have a flask app running in my local laptop with host as 0.0.0.0. When I run this flask app on my windows, I am able to access the endpoints from other laptops/internet. But when I deploy the same flask-app in WSL running in my windows laptop, I am not able to reach to the endpoints from other laptops/internet.

Any suggestions?

I am aware this is not ideal or safe. But I need to enable traffic for few hours to collaborate with a developer working remotely.


Solution

  • I was able to enable the incoming traffic from internet by using ngrok

    The installation was pretty easy. They have details for different OS, since I was using ubuntu I installed it using the following

    curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
    | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null \
    && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" \
    | sudo tee /etc/apt/sources.list.d/ngrok.list \
    && sudo apt update \
    && sudo apt install ngrok
    

    I launched my flask application on 127.0.0.1:5000

    And then in another shell, I started ngrok gateway

    ngrok http --domain=add-the-static-domain-you-get-from-ngrok http://127.0.0.1:5000
    

    And finally, my flask app was reachable at:

    https://add-the-static-domain-you-get-from-ngrok/apistatus