How do I run a java application that wants to bind to ports 80 and 443? Okay, so I turn on my laptop, sign in to my regular user account and proceed to open/run a Java-based, HTTP-proxying application called burp via Terminal.app. It executes normally but refuses to bind with ports 80:http &amp; 443:https. I assume the error is privilege related so I..

user@MacBook-Pro:~$login
login:root
Password:********


..successfuly log in as the root user and..

root@MacBook-Pro:~#open /Users/user/Downloads/burpsuite_free_v1.6.01.jar


..returns the following error:

LSOpenURLsWithRole() failed with error -10810 for the file
/Users/user/Downloads/burpsuite_free_v1.6.01.jar.`


However, I don't observe this error when signed in as a regular user; nor do I observe this error when signed in as root via OS X's graphical user interface.

I'm not sure why burp refuses bind to ports 80:http &amp; 443:https.
If it's merely an error due to (chown) ownership and (chmod) permissions; i would have thought having root access was supposed to transcend such limitations.

Based on this question and answer I can see what the LSOpenURLsWithRole() &amp; error -10810 mean. I'm getting this error because the .jar file isn't a runnable application.

But how do I fix this and get this working on my machine?
You cannot, normally, run a .jar file (which is a Java ARchive file) using the open command on OS X. It's not a executable file, it doesn't give the system any hints about how it should be run normally, so open is giving you the LSOpenURLsWithRole() error you see above.

First, you'll need to install Java on your Mac. The easiest way to do this is to open a Terminal.app window and type:

java -version


If that returns a java version like this:

IanCsiMac:~ |ruby-2.1.5|
&gt; java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)


You're done. Java is ready to be used. If java isn't present on your system, running that command will pop up a window asking if you want to install it. Follow the prompts and when you're done, java -version will show you something like what you see above. The version may be different, but the command will now work.

Now you need to run your .jar file using the java command. You need to provide three options to the java command in order for this to work:


The -jar option which tells java you're running the contents of a Java ARchive file;
A memory option for the Java Virtual Machine in the form -Xmx1024m; and finally
The path to the .jar file on disk.


For your download it's all going to look like this:

java -jar -Xmx1024m /Users/user/Downloads/burpsuite_free_v1.6.01.jar


That will start the program HOWEVER it still won't be able to bind to ports 80 and 443. Those are protected ports. Ports &lt;1024 on any Mac OS X machine can only be bound to be processes started as root.

The correct way to run programs as root is to use the sudo command, not to login as the root user. This provides a level of control and indirection to your actions so you don't do something accidentally silly like rm -rf / without a prompt asking you if you're sure you want to do such a silly thing.

So, the final form of your command will be:

sudo java -jar -Xmx1024m /Users/user/Downloads/burpsuite_free_v1.6.01.jar


You'll be prompted for your password and, assuming nothing else is already bound to ports 80 and 443, your application will start and being listening on those ports.

If it fails because it cannot bind to 80 and 443, you'll need to find out what's bound there already and shut it down. You can use the lsof command to figure this out.

For port 80 the call is:

sudo lsof -iTCP:80 -sTCP:LISTEN -n -P


For 443 it's:

sudo lsof -iTCP:443 -sTCP:LISTEN -n -P


The output from that command, assuming something is listening on the port, will look something like this:

&gt; sudo lsof -iTCP:80 -sTCP:LISTEN -n -P
COMMAND PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
nginx    50 root    9u  IPv6 0x8978b255ac4ef0b7      0t0  TCP *:80 (LISTEN)


As you can see, I have a process named nginx listening port 80. It has process ID 50.

I can kill that process with:

sudo pkill nginx


That doesn't necessarily guarantee it won't try and come back, but how to deal with this fully and completely is best stated as entirely separate question on the site altogether.