How to start Wildfly listens in all the available addresses in the server

Posted on

Introduction

This article has a specific content for showing how to start Wildfly Application Server. It is not only to show how to start it for listening only to the default address. But it also shows how to start Wildfly Application Server to listen in every available addresses in the server. Normally,¬†using a default command, it will start listening in only one default address. The default address ‘localhost’ or ‘127.0.0.1’. But by using an additional parameter for executing Wildfly Application Server, it can start listen on all available addresses in the server.

Starting Wildfly Application Server by default

As a matter in fact, starting Wildfly Application Server is quite simple. By typing a certain command in the command line, it will starts automatically. Follow the steps to start Wildfly Application Server below :

1. In order to start Wildfly Application Server’s service, just type the following command¬† :

standalone.sh

2. Execute the above command to start Wildfly Application Server by default as follows :

user@localhost:/opt/wildfly-14.0.1.Final/standalone/deployments$ /opt/wildfly-14.0.1.Final/bin/standalone.sh 
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/wildfly-14.0.1.Final

  JAVA: java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true 

=========================================================================

21:59:13,546 INFO  [org.jboss.modules] (main) JBoss Modules version 1.8.6.Final
21:59:14,210 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.3.Final
21:59:14,227 INFO  [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final
21:59:14,463 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 14.0.1.Final (WildFly Core 6.0.2.Final) starting
21:59:16,191 INFO  [org.wildfly.security] (ServerService Thread Pool -- 22) ELY00001: WildFly Elytron version 1.6.0.Final
...
21:59:19,328 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:6060
...
21:59:20,955 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 14.0.1.Final (WildFly Core 6.0.2.Final) started in 7847ms - Started 306 of 527 services (321 services are lazy, passive or on-demand)

3. Next, don’t forget to check the address for listening incoming request. It is the request for asking service from Wildfly Application Server. Type the following command :

netstat -tulpn | grep 6060

4. By default, Wildfly Application Server will listen in port 8080. But in the above context, it listens in port 6060. The following is the output of the above command :

root@hostname:~# netstat -tulpn | grep 6060
tcp        0      0 127.0.0.1:6060          0.0.0.0:*               LISTEN      30811/java          
root@hostname:~# 

As it shows in the output above, starting Wildfly Application Server by default will only listens for incoming request in one single address. It is the ‘localhost’ or the ‘127.0.0.1’ address.

Starting Wildfly Application Server for listening to all the available addresses

In the previous section, Wildfly Application Server only listens in one single address. Implementing solution for making Wildfly Application Server listen in every address available in the server is the focus of this article. The solution is actually pretty simple. Just add another additional parameter to the previous command. Just follow the steps below to start listening for Wildlfy Application Server’s incoming request :

1. Just modify the above command as follows :

standalone.sh -b=0.0.0.0

2. The following is the execution of the above command :

user@hostname:/opt/wildfly-14.0.1.Final/standalone/deployments$ /opt/wildfly-14.0.1.Final/bin/standalone.sh -b=0.0.0.0
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/wildfly-14.0.1.Final

  JAVA: java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true 

=========================================================================

22:13:14,171 INFO  [org.jboss.modules] (main) JBoss Modules version 1.8.6.Final
22:13:14,805 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.3.Final
22:13:14,822 INFO  [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final
22:13:15,067 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 14.0.1.Final (WildFly Core 6.0.2.Final) starting
22:13:16,567 INFO  [org.wildfly.security] (ServerService Thread Pool -- 14) ELY00001: WildFly Elytron version 1.6.0.Final
...
22:13:19,516 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0012: Started server default-server.
22:13:19,528 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0018: Host default-host starting
22:13:19,721 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:6060
...
22:13:21,347 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 14.0.1.Final (WildFly Core 6.0.2.Final) started in 7594ms - Started 306 of 527 services (321 services are lazy, passive or on-demand)

3. Finally, don't forget to check the service again by executing the previous command :
root@hostname:~# netstat -tulpn | grep 6060
tcp        0      0 0.0.0.0:6060            0.0.0.0:*               LISTEN      1497/java           
root@hostname:~#

4. There is a difference on the output of the ‘netstat -tulpn’. According to the output above, the service is now listening in every available address in the server. The address ‘0.0.0.0’ is actually representing for all available address in the server.

Leave a Reply