Cannot connect to WildFly CLI? a simple way to solve it

One common issue when you are starting to use WildFly is the following issue. You have tried connecting to the CLI:

$ ./jboss-cli.sh -c

However the following error is returned:

Failed to connect to the controller: The controller is not available at localhost:9990: java.net.ConnectException: WFLYPRT0053: Could not connect to remote+http://localhost:9990. The connection failed: WFLYPRT0053: Could not connect to remote+http://localhost:9990. The connection failed: Connection refused: no further information

As you have specified the connect (-c) option using defaults, CLI tool will try connecting to the default Controller, which is specified in the jboss-cli.xml file:

<default-controller>
    <protocol>remote+http</protocol>
    <host>localhost</host>
    <port>9990</port>
</default-controller>

Therefore, the connection will be performed against that host/port using the protocol remote+http (by default).

In the default configuration, that matches with the CLI management interface which is bound at this address:

<interface name="management">
    <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>

And, in turn, is bound to the following port:

 <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>

That being said. Here are the most common options why you cannot connect to WildFly management port:

1) Simply put, you haven’t started WildFly / JBoss EAP. When using the autoconnect option (-c), the CLI immediately attempts to connect.

2) The management interface is running on a different port/address. It is likely that you have started WildFly with a port offset. In this case, specify the host and port where the Controller is running:

jboss-cli.sh -c --controller=localhost:19990

3) There could be a firewall blocking access to that host/port. You can try telnetting to that port to verify if you reach WildFly. That shows you are able to connect:

telnet localhost 19990
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Found the article helpful? if so please follow us on Socials