Bind WildFly to a different IP address, or all addresses on multihomed (Tech Tip #75)

Interface is a logical name, in WildFly parlance, for a network interface/IP address/host name to which sockets can be bound. There are two interfaces: “public” and “management”.

The “public” interface binding is used for all application related network communication (i.e. Web, Messaging, etc). The “management” interface is used for all components and services that are required by the management layer (i.e. the HTTP Management Endpoint).

By default, “public” interface is configured to listen on the loopback address of 127.0.0.1. So if you start WildFly as:

Then WildFly default page can be accessed as http://127.0.0.1:8080. Usually, /etc/hosts provide a mapping of 127.0.0.1 to localhost, and so the same page is accessible at http://localhost:8080. 8080 is the port where all applications are accessed.

On a multihomed machine, you may like to start WildFly and bind “public” interface to a specific IP address. This can be easily done as:

Now the applications can be accessed at http://192.168.1.1:8080.

For compatibility, -b 192.168.1.1 is also supported but -b=192.168.1.1 is recommended.

Or, if you want to bind to all available IP addresses, then you can do:

Similarly, by default, WildFly can be managed using Admin Console at http://127.0.0.1:9990. 9990 is the management port.

WildFly “management” interface can be bound to a specific IP address as:

Now Admin Console can be accessed at http://192.168.1.1:9990.

Or, bind “management” interface to all available IP addresses as:

You can also bind to two specific addresses as explained here.

Of course, you can bind WildFly “public” and “management” interface together as:

Learn more about it Interface and Port Configuration in WildFly. And more about these switches in Controlling the Bind Address with -b.

Be Sociable, Share!

8 thoughts on “Bind WildFly to a different IP address, or all addresses on multihomed (Tech Tip #75)

  1. Hi Arun,

    Using the -b option i get this [info] message in startup (WildFly 8.2)

    [org.hornetq.jms.server.correctInvalidNettyConnectorHost:1945] HQ121005: Invalid “host” value “0.0.0.0” detected for “http-connector” connector. Switching to “MY_MACHINE_NAME”. If this new address is incorrect please manually configure the connector to use the proper one.

    i can access via localhost, 127.0.0.1 and IP address, but i don’t know if something will work wrong later.

    Thanks a lot and have a nice day

  2. When you are using JMS, connection factories are bound to the connector associated with the option you used on -b.

    these connection factories are available to download remotely, so you would to this at your client.

    In rough terms:

    Context ctx = new InitialContext(…);
    ConnectionFactory conn = (ConnectionFactory)ctx.lookup(“ConnectionFactory);
    conn.createSession(….);; //blablablabla

    The ConnectionFactory here needs a proper IP, and if you bind 0.0.0.0 the client won’t be able to connect to your remote server.

    If you must use 0.0.0.0 then you probably need to remove the remote connection factories from your configuration.

    That would also be an issue with Messaging clustering as the servers will connect to each using an IP on your cluster.

  3. @David: this will probably work fine though. it’s just saying it can’t generate the connector at 0.0.0.0, but you should verify if that’s what you want.

  4. I thought that -b=0.0.0.0 was replaced by following standalone.xml entry?

    I had bad experiences with -b=0.0.0.0 and JBoss AS 7. It works well if you either have a working internet connection or you have no internet connection.
    If you have a bad internet connection (e.g. with a laptop connected via a mobile hotspot in a train) your JBoss takes minutes for startup.
    I guess this is due to some network lookups and waiting for timeouts. If you disable the network connection during startup your JBoss starts running again.
    Took me hours to figure that out. I would not recommend using -b=0.0.0.0 in a development environment and I have no idea why someone would use it in a production environment.

  5. Seems like I can’t enter xml here. The missing standalone.xml entry of my previous comment is: interface name=”public” -> any-address

  6. Flo, using -b=0.0.0.0 instead of <any-address/&ht; in standalone.xml is ok.

    I don’t know why you had the startup time issue. It must be with one of the services that is opening a socket, but it’s hard to say more without some more details.

  7. Might be worth pointing out that 0.0.0.0 does not work for clusters. If used additional configuration on socket-bindings and interfaces are needed.

  8. Have a JAVA_OPTS for this?
    I tried to “-Djboss.bind.address=0.0.0.0” and does not work : (

Leave a Reply

Your email address will not be published. Required fields are marked *