You can get a BindException java.net.BindException: Address already in use if a socket on a machine is already in use and a service (NameNode, JobTracker, DataNode, TaskTracker, HTTP Server, etc.) tries to create a sort on that same port to listen for incoming requests.
- The port is in use (likeliest)
- If the port number is below 1024, the OS may be preventing your program from binding to a "trusted port"
If the configuration is a hostname:port value, it may be that the hostname is wrong -or its IP address isn't one your machine has.
If the port is "0", then the OS is looking for any free port -so the port-in-use and port-below-1024 problems are highly unlikely to be the cause of the problem.
How to track down the problem
- identify which port the program is trying to bind to
as root use netstat -a -t --numeric-ports -p to list the ports that are in use by number and process. (On OS/X you need to use lsof)
- identify the port that is in use and the program that is in use
Make sure the hostname is valid:try to ping it; use ifconfig to list the network interfaces and their IP addresses.
try and identify why it is in use. telnet <hostname> <port> and pointing a web browser at it are both good tricks.
- change the configuration of one of the programs to listen on a different port.