How do I shutdown JBoss Wildfly when I can't access the CLI tool?

Dave picture Dave · Dec 2, 2015 · Viewed 25.1k times · Source

I"m using Wildfly 10.0.0.CR2 with Java 8. I have Wildfly listening for http connections on port 8080 and in the past have used this command to shut down the server ...

./jboss-cli.sh --connect command=:shutdown

HOwever, occassionally, I'm not able to access this tool, even though the server is still running. Note the interaction below on my Mac ...

Daves-MacBook-Pro-2:bin davea$ ./jboss-cli.sh --connect command=:shutdown
Failed to connect to the controller: The controller is not available at localhost:9990: java.net.ConnectException: WFLYPRT0023: Could not connect to http-remoting://localhost:9990. The connection timed out: WFLYPRT0023: Could not connect to http-remoting://localhost:9990. The connection timed out
Daves-MacBook-Pro-2:bin davea$ telnet localhost 8080
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

My question is, what is a foolproof way to shutdown the JBoss server? Note I would prefer a method that does not rely on the CLI tool.

Answer

teacurran picture teacurran · Dec 2, 2015

I suspect that it is sometimes unable to connect because I can see on the telnet that localhost is resolving to ipv6 first. have you tried:

./bin/jboss-cli.sh --connect controller=127.0.0.1:9990 command=:shutdown

Short of that you can always just kill the PID:

pgrep -d" " -f "wildfly" | xargs kill;