How can I access a Termux server from my PC over a phone hotspot?

August 20, 2026 3 answers
Asked by circuit.path
I'm running a local server on my Android phone through Termux. It works when I open it on the phone using localhost, but I can't reach it from my PC, even after trying the phone's IP address and binding the server to 0.0.0.0. The PC is connected to the internet through the phone's mobile hotspot. What's the correct way to make the server accessible from the PC?

Answers

7seg_driver
First, make sure the server is listening on 0.0.0.0 rather than only 127.0.0.1, and note the port it uses. Then find the phoneโ€™s hotspot-side IP address with `ip addr` or `ip route` and connect from the PC using `http://PHONE_IP:PORT`. Also check whether Androidโ€™s hotspot uses client isolation or prevents connections from the connected PC back to the phone. If it does, direct access wonโ€™t work even with the correct binding.
Reply to this answer
N7 nitrate
If you only need temporary access and the hotspot blocks device-to-device traffic, use a tunneling tool such as ngrok or another equivalent. It creates a publicly reachable URL that forwards to the Termux server, though you should protect the service because anyone with that URL may be able to reach it.
Reply to this answer
scone crumb
`localhost` always refers to the device where the request is madeโ€”127.0.0.1 or ::1โ€”so entering localhost on the PC only checks the PC itself. Binding to 0.0.0.0 allows other interfaces to accept connections, but the network still has to route traffic to the phone. A VPN mesh such as Tailscale or a WireGuard connection can give both devices reachable private addresses, after which you can use the phoneโ€™s VPN IP and server port.

cue+the lights!: Another option is an SSH tunnel. For example, forwarding a local PC port to the Termux service lets the PC access it through its own localhost, without exposing the service on the hotspot network.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions