How can I open a specific port on my macOS Yosemite (10.10) system?

2

3

I have a Java based server (jar file) and it is running on port 8080.

It is running well on my localhost, but I can't access it through other networks

I think it's a firewall issue. So first, I tried socketfilterfw:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add 
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp 

hellomac# sudo /usr/libexec/ApplicationFirewall/socketfilterfw --list
ALF: total number of apps = 5 

1 :  /usr/bin/nc 
     ( Allow incoming connections ) 

2 :  /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java 
     ( Allow incoming connections ) 

It doesn't help. Second, add rule in pf.

hellomac# cat /etc/pf.conf 
#
# Default PF configuration file.
#
# This file contains the main ruleset, which gets automatically loaded
# at startup.  PF will not be automatically enabled, however.  Instead,
# each component which utilizes PF is responsible for enabling and disabling
# PF via -E and -X as documented in pfctl(8).  That will ensure that PF
# is disabled only when the last enable reference is released.
#
# Care must be taken to ensure that the main ruleset does not get flushed,
# as the nested anchors rely on the anchor point defined here. In addition,
# to the anchors loaded by this file, some system services would dynamically
# insert anchors into the main ruleset. These anchors will be added only when
# the system service is used and would removed on termination of the service.
#
# See pf.conf(5) for syntax.
#

#
# com.apple anchor point
#
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"

pass in proto tcp from any to any port 8080

But it also doesn't help.

So, what's wrong? what should I do now?

enter image description here

Warlus

Posted 2015-07-01T02:10:53.057

Reputation: 21

I have the same problem, my port forward does not work from an external network request. did you solved it ? Thanks – Daniel Flores – 2015-12-10T08:32:53.237

Answers

0

I just had a similar problem with rails.

The problem is that Yosemite has an application firewall, and although I am sure that there must be a way to open individual ports regardless of the application binding to that port, I could not find a quick and easy way to do it.

Easiest way to do what you are trying to do seems to be adding the "java" executable (JVM) that you use to run your app in the system preferences > security > firewall > firewall options, and it should work.

For example, for opening port 3000 for reaching the rails app I am developing, I added the ruby executable which runs rails and other ruby code running for my project.

To figure out which java (JVM) you are using, use "which java".

Erek Gokturk

Posted 2015-07-01T02:10:53.057

Reputation: 1

I think the first method that I tried before is, a manual way to do that. But it's not woking ... here is my screen shot http://i.stack.imgur.com/LNoJ1.png

– Warlus – 2015-07-02T01:07:43.780

In my case, I have completely disabled the firewall. To allow all ports. No luck still – Santanu Dey – 2015-07-22T11:51:30.810