Linux – Raspberry Pi refuses to connect to the bottle server

Raspberry Pi refuses to connect to the bottle server… here is a solution to the problem.

Raspberry Pi refuses to connect to the bottle server

I’m trying to host bottle server on my Raspberry Pi (4, zero w or zero 2, latest pi OS) to provide some configuration for the project.

The Raspberry Pi itself does not have access to the Internet, but will become its own WiFi access point.
I start with docs The way to set it up is described (search for “setting up routed wireless access points”)
I skipped the Enable Routing and IP Masquerading step because I didn’t need to reroute traffic to another network

The tutorial worked well and I was able to connect to the hotspot. I was also able to run the Bottle server sample and connect to it locally.

However, I can’t connect to it from a device connected to the hotspot. I get a ERR_CONNECTION_REFUSED (when providing the browser with the Raspberry Pi’s IP and the port of the bottle server).

I don’t really know where to start looking
Am I missing my firewall settings?
Should I complete the Enable Routing and IP Masquerading step?
Do I need to see something completely different?

Can someone point me in the right direction?

Solution

Try starting the bottle on the 0.0.0.0 interface instead of localhost. This allows it to listen for incoming connections on all interfaces, whereas if you start with localhost, it will only listen for connections from localhost.

Related Problems and Solutions