• Post Reply Bookmark Topic Watch Topic
  • New Topic

all ports are used-adress already in use

 
Raghuram Chaluvadi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i am trying to create a serversocket and run the following error is coming:-

java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at ServerDemo.main(ServerDemo.java:11)

No matter whatever port number i give the samething is happenning.
This is how i am creating my serversocket:-
ServerSocket s= new ServerSocket(4242);
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is very nearly impossible for a computer to have every single port in use. It is theoretically possible, but so impractical and improbable as to at least be considered, if not truely be, impossible.

I have the feeling that you are attempting to bind the same port twice. Whether this is because of a loop, multiple threads, or whatever, I don't know. But, I would say to take a close look at your code, and debug it, to find out why you are attempting to open the port twice.

It is probably only an honest mistake, but I can almost guarantee (about 99% sure) that this is what is happening.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
many times when you are not running a java program directly , like for example using an IDE .
Sometimes you might not see any activity in the IDE , but the process might be running in the background.Try using an process explorer to see if the program is running or not.If you find the program running , then kill the program and then run your server again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!