Flask, Raspberry Pi, Pi-Hole - Connection Refused

I'm trying my hand at some development. I created a python flask ask that I am running on a raspberry pi (that is also running pi-hole).

I can reach the flask app locally with curl.

curl 
>Hello, World!pi@hole:~/piapi/app $ 

But I cannot reach it from another host on the network:

curl 
>curl: (7) Failed to connect to 192.168.0.2 port 5000: Connection refused

I assumed the port was blocked, but:

netstat -tupln | grep ':5000'
>tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN      30171/python3 

That looks OK wrong to me~, and I can hit the pi-hole web app that runs on port 80. What am I doing wrong? Why can't I reach the flask app on port 5000?

1 Answer

I misunderstood how flask works. I ran flask from the command line flask run, and that ignored the host settings in the python file. Running the app with:

flask run --host=0.0.0.0

See this post for details:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest