Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 02-18-2005, 08:16 PM   #1
LQ Newbie
Registered: Aug 2003
Location: Maryland
Distribution: Debian, Ubuntu, Solaris
Posts: 23

Rep: Reputation: 15
Need Java program to listen on ports < 1024 w/o being root - possible

I am in AP Computer Science 3 on the highschool level and am working on my final project which is a client server chat/poker program written in java. We are not allowed to set up webservers on the school compters, so I trying to use my home linux web server hosting the client applet and also running the poker server program. The poker server listens on port 9999 but it seems that my school blocks outgoing connections to 9999. I know that they do not block ports 80, 21, 22, and 23 (and I assume most ports less than 1024) because I have established connections to my server via telnet.

The problem is: if I am a regular user and I try to run the server on ports less than 1024 I get a java security exception when it tries to bind to the port.

Is there a way to run my server on ports less than 1024 without being root?

Don't apache and other servers do this somehow?



PS I have tried setting the SUID bit for a script to run the server but that did not work, and if it did I think the server would still be running as root.
Old 02-18-2005, 10:51 PM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Binding to priviliged ports (as ports < 1024 are called) is an operation only permitted to the root user. What Apache (and like applications) do is actually start out as the root user, and then drop privileges to a normal user (the apache or nobody account, in most cases). I'm not a Java expert ... so I'm not sure if there's a way around this. Doing a google on Java setuid returned a few hits, so those might be where you want to look. Alternatively, you could do SSH port forwarding to try to get around this, or, if you trust your JVM, let the code run as root (to be avoided).
Old 02-22-2005, 03:12 PM   #3
LQ Newbie
Registered: Aug 2003
Location: Maryland
Distribution: Debian, Ubuntu, Solaris
Posts: 23

Original Poster
Rep: Reputation: 15

Well after performing a google search on java setuid (which returned this thread btw ) I stumbled on something called the java native interface or JNI.

Anyone who has had the same problem as me may want to try the following links:


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Allowing non-root to bind to ports < 1024? MWTJ Linux - Networking 8 08-12-2011 08:06 PM
using privileged ports below 1024 not possible AS ROOT??? flipper333 Slackware 2 01-23-2004 08:35 PM
opening ports below 1024 without being root? meks Linux - Networking 2 12-25-2003 07:05 PM
binding <1024 ports with non root account? linuxlouis Linux - Networking 2 08-11-2003 06:55 PM
Ports below 1024 peo66 Linux - Networking 4 06-14-2003 06:04 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration