java.net.BindException: Address already in use
search cancel

java.net.BindException: Address already in use

book

Article ID: 294023

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

The following exception is seen when starting a GemFire node. This could be either a locator or a server.
java.net.BindException: Address already in use


Resolution

The java.net.BindException occurs due to port conflicts. Specifically, the java.net.BindException means that you're trying to bind to an already used port.


Recommendations to resolve the issue:

1. Identify the process, which is bound to the same port, and then detach the process from the port.

For example:
  • Type netstat -plten |grep java
This will give an output similar to:

tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1001 76084 9488/java

Here 8080 is the port number at which the java process is listening and 9488 is its process id (pid).
  • In order to free the occupied port, we have to detach process 9488 from port 8080 using the kill command.

2. If the issue is noticed with servers, then assign a unique port number to each server, in the “cache.xml” file.

For example:
  • Add the following to your “cache.xml” file
 port="${gemfire.cache.server.port}"

3. If the issue is noticed in the Spring Data GemFire environment, with servers you can try the following:

For example:
  • Pre-assign the ports in the startup scripts in your spring app.
  • Create different profiles with unique port numbers for different servers

References:

java.net.BindException due to port conflicts:
https://docs.spring.io/autorepo/docs/spring-boot-data-geode-build/1.1.0.M2/reference/html5/

Running VMware GemFire Server Processes:
https://gemfire.docs.pivotal.io/910/geode/configuring/running/running_the_cacheserver.html

Address already in use: bind” when running Spring Boot application:
https://stackoverflow.com/questions/34804685/address-already-in-use-bind-when-running-spring-boot-application

Here is a link showing how to configure different ports, in Spring Data GemFire:
https://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#bootstrap