Mac OSX – How to open a port

Lets say you want to check if port 1234 is open, run the following command in the terminal. nmap is not available on mac osx by default.You can install it with Homebrew, my preferred package manager for mac osx. Visit homebrew site for instructions on Homebrew installation.

nmap -p 1234 localhost

This will output the status ..

Nmap scan report for localhost (
Host is up (0.00013s latency).
1234/tcp closed ppp

To open this port, add the following line in /etc/pf.conf

sudo vim /etc/pf.conf

# Open port 1234 for TCP on all interfaces
pass in proto tcp from any to any port 1234
# You can limit the ip addresses .. replace any with allowed addresses ..

Save the file.

I restarted my mac and once I had the application running at port 1234, the status reported by nmap command (mentioned above) changed to ‘open’ and I was able to use my mac’s ip and port to access the application from another computer.

You can also use Network Utility – Port Scan to scan for open ports on your mac.

3 thoughts on “Mac OSX – How to open a port

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s