Skip to content

www.rolfje.com

Open a port in OSX Mavericks’ Firewall

Posted on 2014-05-10 By rolfje 10 Comments on Open a port in OSX Mavericks’ Firewall

FirewallThe new firewall in Mavericks is great. For the common user. For a developer, not so much. If you are a Java developer like me, and you just need to open one port (say, 8080) so that the web application you’re working on is accessable from another computer, you can’t. I disabled the Firewall altogether for a few days, but it didn’t feel right.

I googled around and to make a long story short, here’s how to open port 8080 on any interface to any application on your OSX Mavericks installation in 3 steps:

sudo vim /etc/pf.conf

Then add the following lines at the end of the file:

# Open port 8080 for TCP on all interfaces
pass in proto tcp from any to any port 8080

Test (and, according to the documentation, load) your edits with:

sudo pfctl -vnf /etc/pf.conf

Reboot.

(I have found at least 5 pieces of voodoo to make the Firewall restart and reload, but none of them seemed to work reliably, so pardon the reboot)

You can close it by commenting out the lines in pf.conf and reboot again. If anybody knows of an easier way to do this, preferably in one terminal command, and without rebooting, let me know.

Hope this helps.

Software Tags:Apple, firewall, Java, programming, security, usability

Post navigation

Previous Post: There’s life without Google. Or iCloud. Or Facebook.
Next Post: Print posters on a regular printer with Excel.

Comments (10) on “Open a port in OSX Mavericks’ Firewall”

  1. bilunov77 says:
    2014-05-17 at 06:41

    Reblogged this on Dirigeant.societe.com.

    Reply
  2. Derek says:
    2014-06-19 at 21:34

    When I ran this command:

    sudo pfctl -vnf /etc/pf.conf

    It said there was bad syntax on this line:

    pass in proto tcp from any to any port 8080

    Reply
    1. rolfje says:
      2014-06-19 at 23:36

      Strange, I just double-checked my config and your line looks identical. Did you put the line at the end of the existing file and did you check for line endings, tabs and perhaps characters that look like spaces but really aren’t?

      Reply
      1. Joyce Babu says:
        2014-07-05 at 13:17

        I too got the same error. Fixed it by adding a new line after the rule.

        Reply
  3. Joyce Babu says:
    2014-07-05 at 13:18

    Restarting the firewall via “System Preferences > Security & Privacy > Firewall > Turn Off Firewall” worked for me.

    Reply
  4. Pingback: Apple:How to open a specific port in Firewall OS X 10.9.4 – Apple Questions
  5. Pingback: How do I open a specific port on OS X Yosemite from the command line? - osx
  6. Julie Jones says:
    2016-08-02 at 00:18

    El Capitan: whole lotta no workie

    Reply
  7. Rohit says:
    2017-02-01 at 15:24

    How do I add a line to the pf.conf. I am a newbie to mac

    Reply
  8. rolfje says:
    2017-02-01 at 21:54

    The very first command in the article opens “vim”, an arcane text editor very commonly seen on Unix systems. You can use your arrow keys to move to the last line of the editor.

    To add the line, press “Shift-A” (your cursor should now be at the end of the last line. press “Enter” and Copy/Paste the lines from the article in your terminal window.

    To save the file and exit the editor, press “Esc”, then type “:wq” and hit “Enter”.

    If this doesn’t work please find a good vim tutorial online, there are quite a few good ones out there.

    (By the way I use vim regularly, but I’m not a fan. https://rolfje.wordpress.com/2008/04/05/the-vi-religion/ )
    😉

    Good luck!

    Reply

Leave a Reply to Julie Jones Cancel reply

Your email address will not be published. Required fields are marked *

           

Recent Comments

  • rolfje on Methode Buijs uitgelegd
  • LinkedIn is at Peak Enshittifaction – Will Chatham's Blog on Linked-In not really Opt-in?
  • Hans j on 1N4148 diode as RF switch
  • Roaming Rhonda on DLNA on OSX, done right
  • Frans on How to fix a Krups XN2001 Nespresso machine

Tags

Anonimatron Apple backup design DIY DRM eclipse environment Fun gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Keynote maven modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software Steve Jobs T-Mobile technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (105)
  • Divorce (1)
  • Electronics (3)
  • Fun (57)
  • Games (7)
  • Hardware (72)
  • Microsoft (18)
  • Racing (14)
  • Software (134)
  • Uncategorized (65)
  • Workshop (20)

Archives

Copyright © 2025 www.rolfje.com.

Powered by PressBook WordPress theme