OSX Lion, open a local port so people on my network can access it
Solution 1
System Preferences > Security & Privacy > Firewall > Advanced.
Add a new entry with the +
. Since you're running an executable, you can search for python
, or you could add an entry using the port via command-line and ipfw
.
More info here: https://serverfault.com/a/105736/3914
Solution 2
python manage.py runserver
The above command will permit access by localhost only. If you want to permit access by other network devices you must serve on 0.0.0.0
:
python manage.py runserver 0.0.0.0:8000
For those running from PyCharm, you set the Host field to 0.0.0.0
in the Run Configuration.
Once I did this, I got the OS X firewall popup asking: Do you want the application “Python.app” to accept incoming network connections.
Then you can access via mac-name.local:8000
or via the Mac's ip address.
Incidentally, I'm running Python 3.4, built and installed by MacPorts on OS X El Capitan 10.11.2.
n0pe
Updated on September 18, 2022Comments
-
n0pe over 1 year
I'm running django's simple HTTP server (using
python manage.py runserver
). It's currently running on port 8000.How can I open a port on my macbook and allow network traffic to visit my host on port 8000?
-
Admin about 12 yearsIf it's running on port 8000, the port is already open. What are you asking? Perhaps you'll need an exclusion in your firewall for that port, but it's not clear from your question.
-
n0pe about 12 yearsThe port is open to me locally, but is most likely being blocked by my computer's firewall. I need to open it.
-