Is it safe to run python -m http.server XXXX

1k Views Asked by At

I am trying to run a html project that I have started. I need to do so on a local server to reach full capabilities for the java aspect. I've been told that "python -m http.server 8000" is a good way of going however is this safe and will my information on my computer be compromised or is this 100% local? I only ask because my Firewall didn't like the idea of me running this server.

Thank you in advanced.

1

There are 1 best solutions below

4
tiblu On BEST ANSWER

By default the HTTP server binds to all interfaces which opens it up to the World thus the firewall complains. If you use it only from localhost, use --bind parameter to only bind to localhost.

Full command: python -m http.server 8000 --bind 127.0.0.1

Source: https://docs.python.org/3/library/http.server.html

Note: --bind was introduced in Python 3.4, so you need 3.4 or newer to use --bind.