This guide contains some tips to teach you how to start, stop, restart WildFly application server. By the end of this tutorial, you will be able to effectively manage the lifecycle of your Wildfly server as needed. Besides, we provide some troubleshooting tips to verify why the start or restart does not work.
Firstly, WildFly can be run in two modes: Standalone mode and Domain mode.
Booting WildFly in Standalone mode
You can start WildFly as follows. Move into the bin folder of your installation and run:
$ ./standalone.sh
The above command will start WildFly with the default (standalone.xml) configuration. If you want to provide another configuration available, just pass it as argument:
$ standalone.sh -c standalone-full.xml
The recommended way to stop WildFly is by connecting to it via its management interface (jboss-cli.sh):
$ ./jboss-cli.sh
Then, from there execute:
[standalone@localhost:9990 /] shutdown
You can restart the application server, passing it as argument to shutdown:
[standalone@localhost:9990 /] shutdown --restart=true
Finally, you can also specify in a timeout for the shutdown as follows
[standalone@localhost:9990 /] shutdown --timeout=10
If there is no timeout specified it will wait indefinitely.
Finally, please notice that you can also issue the shutdown command in non-interactive way. For example:
./jboss-cli.sh -c --commands=":shutdown"
Booting WildFly in Domain mode
You can start WildFly Domain as follows. Move into the bin folder of your installation and run:
$ ./domain.sh
Firstly, the recommended way to stop WildFly is by connecting to it via its management interface (jboss-cli.sh):
$ ./jboss-cli.sh
To Stop all servers in a Host:
/host=master:stop
To restart all servers in a Host:
/host=master:stop(restart=true)
To Stop a single server in a Host:
/host=master/server-config=server-one:stop
Finally, to restart a single server in a Host:
/host=master/server-config=server-one:stop(restart=true)
To learn mode about Domain mode we recommend checking this article: WildFly / JBoss Domain configuration
How to start, stop, restart WildFly when the CLI is not available
If you have a Management user, you can still Start, Stop and Restart WildFly using the Web Console which is available at http://localhost:9990
When running in Standalone mode, select the Runtime upper Tab and, from your Server name, click on the Combo Menu’s arrow. You should be able to Reload, Restart or Suspend the Server from there:

Much the same way, when running in Domain mode, you can perform the same Management actions on your Domain Host, on Server Groups or on Individual Servers:

Integrate Systemd management
WildFly’s official documentation now provides robust systemd support for Linux services. Key steps:
cd $WILDFLY_HOME/bin/systemd ./generate_systemd_unit.sh standalone <user> <group>
This creates customized unit files for standalone/domain mode.
Essential service commands:
systemctl start wildfly-standalone # Start service systemctl restart wildfly-standalone # Graceful restart systemctl stop wildfly-standalone # Stop service
Critical configuration: Set TimeoutStopSec=90 in the unit file to prevent premature termination during shutdown. To learn more about Starting WildFly as service check this article: How to run WildFly as Service
Planning a restart of your Servers in Domain Mode
Over time, Java applications can accumulate memory leaks or hold onto unused resources. Therefore, it is fairly common to have a scheduled restart of Application Servers when your applications are not active. For example, during the weekends or at night. Planning a restart of standalone servers is a trivial task as it is just a matter of starting and stopping a process.
In domain mode, if you want to perform a safe restart of your servers, a best practice is to stop and start each server. Therefore, even if there is a limited number of users, they will still be able to use your applications, provided that you have deployed your applications on at least two nodes.
The good news is that you can do it with just a simple and powerful CLI command:
/server-group=main-server-group:restart-servers{rollout main-server-group(rolling-to-servers=true)}
In the above command, by setting rolling-to-servers on your Server groups allows to apply the operation to each server one by one. If you don’t specify it, the operation applies to the servers in the group concurrently.
If you need more control over the Server Restarts ( such as logging or extra operations) you can still use a simple shell script that iterates over the Host Controller to loop over the Servers one by one.
You can then add this script to your crontab for a periodic restart:
CLI="/home/jboss/wildfly-32.0.0.Final/bin/jboss-cli.sh"
HOSTS=$($CLI -c --commands="cd /host, ls")
read -r -a host_array <<< "$HOSTS"
# Loop through the hostcontrollers
for hostcontroller in "${host_array[@]}"; do
echo "HOST: $hostcontroller"
SERVERS=$($CLI -c --commands="cd /host=$hostcontroller, ls server")
read -r -a host_servers <<< "$SERVERS"
# Loop through the servers
for jbossnode in "${host_servers[@]}"; do
echo "├── $jbossnode"
$CLI -c --commands="/host=$hostcontroller/server-config=$jbossnode:stop(blocking=true)"
if [[ $? -eq 0 ]]; then
echo "$jbossnode successfully stopped"
else
echo "Error when stopping $jbossnode $?"
fi
sleep 5
$CLI -c --commands="/host=$hostcontroller/server-config=$jbossnode:start(blocking=true)"
if [[ $? -eq 0 ]]; then
echo "$jbossnode successfully started"
else
echo "Error when starting $jbossnode $?"
fi
done
done
As you can see, all you have to customize is the location of WildFly CLI, Then, it will loop over each Host Controller and then loop through each Server in the Host. You could make it a bit shorter by using the command “/host=$hostcontroller/server-config=$jbossnode:restart(blocking=true)“. However, by using the stop/start command allows some additional tracing of your commands and some extra time to allow closing socket/resources
Managing the lifecycle of WildFly via JMX
Finally, you can also use JMX to manage certain operations such as shutdown or shutdown with restart using JMX.
The simplest way to do that, is to connect to a tool, for example JConsole, and then access the jboss.as:management-root=server MBean. For example, to shutdown the application server:

Besides, you can also operate through the javax.management and perform the shutdown programmatically. For example:
public static void status() throws Exception{
String host = "localhost";
int port = 9990; // management-http port
String urlString = "service:jmx:remote+http://" + host + ":" + port;
System.out.println("\n\n\t**** urlString: "+urlString);;
JMXServiceURL serviceURL = new JMXServiceURL(urlString);
Map map = new HashMap();
String[] credentials = new String[] { "admin", "admin" };
map.put("jmx.remote.credentials", credentials);
JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, map);
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
ObjectName mbeanName = new ObjectName("jboss.as:management-root=server");
connection.invoke(mbeanName, "shutdown", null, null);
jmxConnector.close();
}
Conclusion
This article was a walk through a set of options to manage the lifecycle of the application server using different tools (CLI / Web Console / JMX API). You should now be able to manage the lifecycle of the server effectively.