Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Sockets and Internet Protocols and the fly likes Ports under 1024 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Ports under 1024" Watch "Ports under 1024" New topic
Author

Ports under 1024

Len Padson
Ranch Hand

Joined: Nov 21, 2011
Posts: 40
On my mac, I cannot create a server on any port less than 1024. How do I fix this? Id like to not have to use port forwarding, but if that is necessary, could somebody please explain how? Thank you!!!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18757
    
  40

Len Padson wrote:On my mac, I cannot create a server on any port less than 1024. How do I fix this? Id like to not have to use port forwarding, but if that is necessary, could somebody please explain how? Thank you!!!


I believe that only the root user can use ports less than 1024 -- and it is likely for a security reason. So, your only option is to run your program as the root user.

Henry

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Henry Wong wrote:
Len Padson wrote:On my mac, I cannot create a server on any port less than 1024. How do I fix this? Id like to not have to use port forwarding, but if that is necessary, could somebody please explain how? Thank you!!!


I believe that only the root user can use ports less than 1024 -- and it is likely for a security reason. So, your only option is to run your program as the root user.

Henry


Yes, that is correct. I know that certain Linux flavors support administrative options that let non-root users open ports < 1024, but I don't know if Mac has something similar. I'd avoid those ports if possible, and if not possible, you'll have to do it as root. Turning on the setuid bit on your java executable may also work, but that's pretty risky in itself.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ports under 1024