9

I'm trying out the command python http.server from the command line, and am trying to access the server. I can access easily from localhost, but whenever I try to use a remote connection, I am unable to connect.

I've tried different ports, and it doesn't look like my firewall is blocking any connections.

From the command line, I run

python3 -m http.server 8000

which returns

Serving HTTP on 0.0.0.0 port 8000 ...

However, I can only connect to the server from localhost.

sudo iptables -S

returns the following:

-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT

I expect to be able to connect from a remote host with the url http://10.247.30.125:8000 (my ip address), but I am unable to do so. The same url works fine on localhost.

2
  • 1
    It's likely you need to port forward. You can also want to google ngrok Commented Apr 23, 2019 at 23:32
  • I think this is a network configuration question, not a programming question. "0.0.0.0" means it is listening on all available interfaces. If you can't reach it, it's because none of your interfaces receives traffic for the address you're trying to use. Commented Apr 24, 2019 at 13:20

2 Answers 2

4

I figured out what was going on. Did some reading about IP and NAT, and noticed that any ip address beginning with a 10 is reserved for private ip addresses. So, trying to connect to 10.247.30.125:8000 from anywhere other than my own network (so while not connected to my wifi) doesn't work. To be able to connect from an external network, I would need to set up port forwarding (like Reedinationer suggested), and I would need to use my router's public IP address rather than my computer's private IP address. I would set up a port forward from my router to direct external traffic to my computer, which would allow me to connect to my personal computer from an external network.

Thanks to everyone who responded!

Sign up to request clarification or add additional context in comments.

Comments

0

port is missing from the url try this url it should work "http://10.247.30.125:8000"

1 Comment

good point, that's what I actually tried I just made a typo in the post. I have the same error with "10.247.30.125:8000". I edited the post to reflect this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.