# Restarting and reloading the Wazuh 4.14 manager via the API: what happens underneath and when it fails

> PUT /manager/restart, /cluster/restart and analysisd/reload in Wazuh 4.14: the execq and com socket path, validation, error 1017 and a safe procedure.

Published: 2026-12-03. Updated: 2026-12-04. Category: Configuration. Tags: Wazuh 4. URL: https://wazuh.blog/en/blog/wazuh-manager-reload-vs-restart/ Polish original: https://wazuh.blog/blog/wazuh-reload-restart-managera/

A 202 response to `PUT /manager/restart` only means the request reached the socket. It does not confirm that the manager restarted. What the Wazuh 4.14 API does next on restart, ruleset reload and configuration validation is only partly documented; the 4.14.11 code shows the rest.

Values in the examples are synthetic: host `example.com`, node `worker1`. Behavior marked "in the 4.14.11 code" is not guaranteed by the documentation and may change in later releases.

## Endpoints

| Endpoint | RBAC permissions | Response |
|---|---|---|
| `PUT /manager/restart` | `manager:read`, `manager:restart` | 202 |
| `PUT /cluster/restart` (parameter `nodes_list`) | `cluster:read`, `cluster:restart` | 202 |
| `PUT /manager/analysisd/reload` | `manager:read`, `manager:restart` | 200 |
| `PUT /cluster/analysisd/reload` (parameter `nodes_list`) | `cluster:read`, `cluster:restart` | 200 |
| `GET /manager/configuration/validation` | `manager:read` | 200 |
| `GET /cluster/configuration/validation` | `cluster:read` | 200 |
| `PUT /manager/configuration` | `manager:update_config` | 200 |
| `PUT /cluster/{node_id}/configuration` | `cluster:update_config` | 200 |
| `GET /manager/status`, `GET /cluster/{node_id}/status` | `manager:read`, `cluster:read` | 200 |

The API reference in the documentation is a ReDoc page, so endpoint details come from the specification `api/api/spec/spec.yaml` at tag 4.14.11. The permissions for restart and for reload are the same, and `PUT /manager/configuration` restarts nothing: it writes the file and validates it (see below). Deploying the rule files themselves is covered in the [post on rules from a repository](/en/blog/wazuh-rules-from-repository/), restarting agents in the [post on restarting agents via the API](/en/blog/agent-restart-api/).

## Restart: the path from request to processes

In the 4.14.11 code, the `manager_restart()` function in `framework/wazuh/core/cluster/utils.py` does three things:

1. Takes an `fcntl.lockf` lock on the file `var/run/.api_execq_lock`.
2. Sends a JSON datagram with the `restart-wazuh` command to the `queue/alerts/execq` socket.
3. Releases the lock and returns `Restart request sent`, without reading a reply.

The lock only serializes sends from the API itself. The API code does not check whether a restart is already in progress, so there is no error code for "restart in progress". Two restart requests sent one after the other will both go through.

On the other side of the socket, `wazuh-execd` runs `active-response/bin/restart.sh manager`. The script has two steps that matter to an operator:

- Before the restart it runs `bin/wazuh-logtest-legacy -t`. If the rule and decoder test fails, the script exits with code 1 without any message, and the API has already answered 202.
- Then, on a system with systemd, it calls `systemctl restart wazuh-manager`, and without systemd `bin/wazuh-control restart`.

So after a 202, check the daemon state. The `wazuh-control` documentation recommends restarting through `systemctl` or `service`, because that avoids a mismatch between the service state and the process state.

### What wazuh-control restart does

The `restart_service` function in the `wazuh-control` script (in the 4.14.11 code it is `src/init/wazuh-server.sh`, installed as `bin/wazuh-control`) creates the file `var/run/.restart`, runs `testconfig`, stops and starts the services, and finally removes `.restart`. `testconfig` calls `bin/<daemon> -t` for each daemon. On an error it prints `<daemon>: Configuration error. Exiting`, removes `var/run/*.start` and `.restart`, and exits with code 1. The start step also repeats `wazuh-logtest-legacy -t`; output containing `ERROR` stops the start and creates `var/run/wazuh-analysisd.failed`.

The script also takes its own lock: the directory `var/start-script-lock`, retrying every second, with the constant `MAX_ITERATION="60"`. After 60 attempts it exits with `ERROR: Another instance is locking this process.` and a request to remove the directory manually if no other instance is running. A comment in the code mentions 10 attempts, but the constant is 60.

The reload mode in `wazuh-control` (`reload`) restarts all processes except `wazuh-execd`. The API does not use this mode: `execd` passes only the argument `manager` to `restart.sh`.

## Error 1017: daemons are not ready

Error 1017 means that one of the daemons is not ready. The message in `framework/wazuh/core/exception.py` reads: `Some Wazuh daemons are not ready yet in node "{node_name}" ({not_ready_daemons})`. Before executing any API function (except the status read), `check_wazuh_status()` in `dapi.py` checks five daemons: `wazuh-modulesd`, `wazuh-analysisd`, `wazuh-execd`, `wazuh-db` and `wazuh-remoted`. If any of them is in the state `failed`, `restarting` or `stopped`, the API returns 1017.

`get_manager_status()` determines the daemon state in this order: the file `var/run/<daemon>.failed` gives `failed`, then the presence of `var/run/.restart` gives `restarting`, then `<daemon>.start` gives `starting`, and finally the pid files and the process in `/proc` decide. Two conclusions:

- During `wazuh-control restart`, all daemons without a `.failed` file report `restarting`, so ordinary API calls return 1017, while `GET /manager/status` keeps working.
- A `var/run/.restart` file left behind by an interrupted restart should keep this state (that comes from reading the code, not from a test). The documentation does not describe how to remove such a file. Before you delete it by hand, make sure no `wazuh-control` is running.

## Configuration validation before a restart

`GET /manager/configuration/validation` and `GET /cluster/configuration/validation` both accept `wait_for_complete`. The `validate_ossec_conf()` function sends the `check-manager-configuration` command to the `queue/sockets/com` socket. In `wazuh-execd` (`wcom_check_manager_config` in the 4.14.11 code):

1. The `ossec.conf` file is parsed as XML.
2. `bin/<daemon> -t` is run in sequence for `wazuh-authd`, `wazuh-remoted`, `wazuh-execd`, `wazuh-analysisd`, `wazuh-logcollector`, `wazuh-integratord`, `wazuh-syscheckd`, `wazuh-maild`, `wazuh-modulesd`, `wazuh-clusterd`, `wazuh-agentlessd` and `wazuh-csyslogd`, each with a limit of 2000 s. The array in `wcom.c` (lines 401-405) lists `wazuh-integratord` twice, so that is 13 `-t` calls for 12 distinct daemons.
3. The first non-zero exit code stops the check.

On an error the API returns code 1908, `Error validating configuration`, with the daemon messages and the hint `Please, fix the corrupted files`. A correct result is an entry with `status: OK` for the node in `affected_items`.

The list does not include `wazuh-db`, `wazuh-monitord` or `wazuh-apid`. The `wazuh-logtest-legacy -t` test appears only in `restart.sh` and in `wazuh-control`. What exactly `analysisd -t` and logtest verify, and what they do not, is covered in the [post on rule validation gaps in CI](/en/blog/wazuh-ruleset-validation-ci/).

`PUT /manager/configuration` uses the same validation. The 4.14.11 code (`update_ossec_conf`) checks that the body is valid XML, copies `ossec.conf` to `ossec.conf.backup` (error 1019 on failure), writes the new file and runs the validation. Any result other than `OK` gives error 1125, `Invalid ossec configuration`, and the copy is restored. On success the service keeps running on the old configuration until a restart.

## Ruleset reload: analysisd/reload

The specification describes `PUT /manager/analysisd/reload` as reloading the analysisd process. The 4.14.11 code shows that this is a hot reload, without restarting the process:

- On the master or a single manager, the API sends the `reload-ruleset` command to the `queue/sockets/analysis` socket. On a worker, the `reload_ruleset` function sets the reload flag through the local cluster client and returns `Ruleset reload request sent successfully.` or `Failed to send the ruleset reload request.`
- Analysisd reads the `ruleset` section of `ossec.conf` and builds a new set of decoders, CDB lists and rules. The other configuration sections are not loaded in the process.
- If the build fails, the `w_hotreload_reload` function returns before taking any lock, so the existing set keeps running. The API then returns error 1914, `Failed to reload ruleset`, with the analysisd messages.
- If it succeeds, the input and matching threads are blocked, and events waiting in the intermediate queues (`decode_queue_event_output` and the write queues) are dropped without being processed. The log shows the entries `Reloading ruleset` and `Ruleset reloaded successfully`.

Warnings from loading come back in the `msg` field of the `affected_items` element. The dropping of events from the intermediate queues comes from the code alone: the documentation does not mention it, so a reload under heavy traffic may lose events. Up to 4.14.10 it could also crash `wazuh-analysisd`: the 4.14.11 CHANGELOG lists a fix for the crash on a reload from the dashboard or the API while events were being processed (#40907). In the 4.14.11 code this is done by the `w_hotreload_drain_queues` function (`analysisd.c`, lines 2574-2600), called from `w_hotreload_reload` (line 2526) and releasing each event through `Free_Eventinfo` (line 2570). How many events are lost depends on how full the queues are at the moment of the reload; I have no measurement from a running instance.

On a worker, the response `Ruleset reload request sent successfully.` only means that `wazuh-clusterd` set a flag. The reload happens at the end of the next integrity check with the master, which repeats about every 9 s, so the worker reloads the rules after it has fetched the changed files. The API does not return the reload result. The worker writes it to its cluster log: `Ruleset reload triggered by cluster integrity check: reload message sent successfully.` `Ruleset reloaded with warnings after cluster integrity check:` followed by the warnings, or `Ruleset reload failed after cluster integrity check:` followed by the errors. File synchronization alone, without that flag, does not start a reload (that comes from reading the code, not from a test).

## Time limits

The documentation gives `request_timeout` = 10 s as the default API response limit. In the 4.14.11 code the limit does not apply when you pass `wait_for_complete`; the validation and reload endpoints accept this parameter, `PUT /manager/restart` does not. Validation runs a dozen or so `-t` processes in sequence, so on a slower node add `wait_for_complete=true`. The other limits in the 4.14.11 code are the 60 lock attempts of `wazuh-control`, the 60 s wait in the `reload` branch of `restart.sh` (not used by the API) and the 2000 s per daemon in validation.

## Restarting a cluster node by node

I suggest this order, which uses only the API:

1. Validate the configuration on the node: `GET /cluster/configuration/validation?nodes_list=worker1&wait_for_complete=true`. Continue only on `status: OK`.
2. Restart one node, `PUT /cluster/restart?nodes_list=worker1`, and treat 202 as "sent".
3. Poll `GET /cluster/worker1/status` until the five base daemons report `running`. Error 1017 or a lost connection during this time is expected, because the API is restarting itself.
4. If the state does not come back, check `ossec.log` and the presence of `var/run/*.failed` before repeating the restart.
5. Only then the next node, and the master last.

The `safe-restart.sh` script implements steps 1 to 3. I tested the script (bash 5.3, jq 1.8) against a `curl` mock with responses I prepared, not against a running cluster. With two 1017 responses and then a `running` status, the script ends with the message `node worker1 ready after poll 3` and exit code 0, and with a validation response carrying error 1908 instead of `OK`, it ends with `validation: FAILED` and exit code 1. The `-k` option in the `CURL` array turns off API certificate verification. If the API certificate comes from your CA, replace it with `--cacert` and the path to the CA file.

```bash
#!/usr/bin/env bash
# Validate, restart one node, wait until the API reports basic daemons running.
set -euo pipefail

API="${API:-https://example.com:55000}"
NODE="${NODE:-worker1}"
CURL=(curl -sk -H "Authorization: Bearer ${TOKEN:?set TOKEN}")

# 1. Validation on the node (wait_for_complete avoids the 10 s request_timeout)
status=$("${CURL[@]}" "$API/cluster/configuration/validation?nodes_list=$NODE&wait_for_complete=true" \
  | jq -r '.data.affected_items[0].status // "FAILED"')
[ "$status" = "OK" ] || { echo "validation: $status" >&2; exit 1; }

# 2. Restart one node; 202 only means the request was sent
"${CURL[@]}" -X PUT "$API/cluster/restart?nodes_list=$NODE" \
  | jq -e '.data.total_failed_items == 0' >/dev/null

# 3. Poll daemon status; 1017 or a connection error means "not ready yet"
for i in $(seq 1 30); do
  sleep "${POLL_SLEEP:-5}"
  out=$("${CURL[@]}" "$API/cluster/$NODE/status" 2>/dev/null || true)
  if echo "$out" | jq -e '.data.affected_items[0]
       | [."wazuh-analysisd", ."wazuh-remoted", ."wazuh-modulesd", ."wazuh-db", ."wazuh-execd"]
       | all(. == "running")' >/dev/null 2>&1; then
    echo "node $NODE ready after poll $i"; exit 0
  fi
done
echo "node $NODE not ready" >&2; exit 1
```

The cluster layout, the master and worker roles and process control are covered in the [post on cluster operations](/en/blog/wazuh-cluster-operations/).

## Sources

- https://documentation.wazuh.com/4.14/user-manual/api/reference.html
- https://documentation.wazuh.com/4.14/user-manual/api/configuration.html
- https://documentation.wazuh.com/4.14/user-manual/reference/tools/wazuh-control.html
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/api/api/spec/spec.yaml
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/cluster/utils.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/cluster/dapi/dapi.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/manager.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/manager.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/analysis.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/analysis.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/exception.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/active-response/restart.sh
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/init/wazuh-server.sh
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/os_execd/wcom.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/analysisd/analysisd.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/analysisd/asyscom.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/cluster/worker.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/cluster/local_server.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/cluster/control.py
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/framework/wazuh/core/cluster/cluster.json
