Search code examples
pythonflaskhostingfritzbox

Python Flask can't host Backend on my machine


So I wanted to host my backed on my machine for my website. The Problem is I can't the frontend works perfectly but the Flask backend doesn't. The backend works when I use localhost or my local ip to access it. But doesn't work when I try to use it with the link :
https://desktop-1234567.1234567890qwert.myfritz.net:3182 (this one is fake) It displays this error message : Cant find it So basically it says that it can't find the backend the Flask backend also dosen't react. Even though I port forwarded the port 3182 with my-Fritz : I port forwarded it I also turned off Windows Firewall and it dosen't help

My Fritz is basically a free service from avm for Firtz-Box users (that's my Router) It generates a sub domain where all your traffic is routed through this is useful since this url is static.

I tried it with a simpler backend :

from flask import Flask

app = Flask(__name__)

@app.route("/test")
def test():
    return "<h1>Test</h1>"


if __name__ == "__main__":
    app.run(
        debug=False,
        host='0.0.0.0',
        port=3182,
        threaded=True
    )

and it also doesn't work it gives the same error message as above. I also tried using waitress to host this simple app but it also won't work.

It has to be Flask since I can access my Frontend with the link on port 80 and 443.

I'm on Windows 10 and I hope somebody knows why this isn't working.

So yeah pleas help me I searched and it appears that no one had this exact problem before (But you never know on Stack Overflow)


Solution

  • Well I found out what the issue is. The Issue is that I used "0.0.0.0" as the host parameter to run the app. This tells flask to use IPV4, however I looked in to it and found out that "My Fritz" uses IPV6 so I just had to change the host parameter to use IPV6 by replacing "0.0.0.0" with ::.

    That's it hope it helps, if anyone runs into the same issue as me.