• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to resolve java.net.BindException

 
Binesh Veetil
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a new ServerSocket object and I am getting the following error:
java.net.BindException: Cannot assign requested address: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)

Code to create server socket is as follows:
server = new ServerSocket(port, 0, hostInetAddress);

Please help me resolve this.
 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Binesh Veetil wrote:I am trying to create a new ServerSocket object and I am getting the following error:
java.net.BindException: Cannot assign requested address: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)

Code to create server socket is as follows:
server = new ServerSocket(port, 0, hostInetAddress);

Please help me resolve this.



The issue is simple. A process is already bound to the port in questions. Are you on a linux box or a window box?

Cheers,
Philip
 
Binesh Veetil
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Philip Thamaravelil wrote:

The issue is simple. A process is already bound to the port in questions. Are you on a linux box or a window box?

Cheers,
Philip


I am on linux box.
 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Binesh Veetil wrote:
Philip Thamaravelil wrote:

The issue is simple. A process is already bound to the port in questions. Are you on a linux box or a window box?

Cheers,
Philip


I am on linux box.




so, to determine what process id is running on your port, run:

 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Philip Thamaravelil wrote:The issue is simple. A process is already bound to the port in questions.

Not necessarily. On Linux and Unix regular users cannot open ports below 1024. You need root access for that.
 
Binesh Veetil
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Not necessarily. On Linux and Unix regular users cannot open ports below 1024. You need root access for that.

What do you mean by root access? Will I be able to do a telnet from IP to another like : <telnet IP Port> port numbers which I am using are below 1024 as well.
 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Binesh Veetil wrote:
Rob Spoor wrote:Not necessarily. On Linux and Unix regular users cannot open ports below 1024. You need root access for that.

What do you mean by root access? Will I be able to do a telnet from IP to another like : <telnet IP Port> port numbers which I am using are below 1024 as well.



telenet'ing to another machine is completely unrelated to your ability to bind a process to a port on the local machine.

In your post, you mentioned your trying to start an application that will bind and listen on port XXXX. Rob makes a great point, that you either need to select a port number > 1024 OR you must run the process as the user root. IMO, your better off selecting a higher numbered port as your less likely to run into port conflicts with another process.

Cheers,
Philip
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Binesh Veetil wrote:
Rob Spoor wrote:Not necessarily. On Linux and Unix regular users cannot open ports below 1024. You need root access for that.

What do you mean by root access? Will I be able to do a telnet from IP to another like : <telnet IP Port> port numbers which I am using are below 1024 as well.

Connecting to a port with a client is allowed for any user. Otherwise you couldn't even browse the web. The 1024 limitation only exists for listening to incoming connections.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic