# Disconnected Wazuh agents: keepalive and agents_disconnection_time

> When the Wazuh manager marks an agent as disconnected: keepalive, agents_disconnection_time and its alert, notify_time, the agent state file, API and wazuh-db.

Published: 2026-11-12. Category: Analysis. Tags: Wazuh 4. URL: https://wazuh.blog/en/blog/wazuh-agent-disconnections/ Polish original: https://wazuh.blog/blog/wazuh-agent-rozlaczenia/

The `Disconnected` status in Wazuh means the manager did not receive a keepalive message from the agent within the configured time. That moment depends on settings on both sides: the threshold in `<global>` on the manager and the check-in interval in `<client>` on the agent. You can read the status in the dashboard, through `agent_control`, through the API and in the local agent state file.

## Four connection states

The agent life cycle covers installation and enrollment, connection states and removal. After enrollment, the manager keeps information about the agent and its connection status until the user deletes it. Deletion happens through the Wazuh server API or from the command line.

| State | Description in the documentation |
| --- | --- |
| `Never connected` | The agent is registered but has not connected to the manager yet |
| `Pending` | The manager received a connection request but nothing more, authentication has not finished |
| `Active` | The agent is connected and can communicate with the manager |
| `Disconnected` | The manager did not receive a keepalive within `agents_disconnection_time`, 15 minutes by default |

The agent passes through the `Pending` state once in each cycle after startup. According to the documentation, staying in this state can point to a connectivity problem.

## Threshold on the manager side

`agents_disconnection_time` in the `<global>` block of the manager `ossec.conf` sets the time since the last keepalive after which the manager treats the agent as disconnected. The default is `15m`, the minimum is `1s`. A positive number with the unit `s`, `m`, `h` or `d` is allowed. The documentation notes that the value should always be greater than `notify_time` configured on the agents.

`agents_disconnection_alert_time` sets the time after which an alert is raised, counted from the moment the agent is treated as disconnected. The default and minimum is `0s`, which means an alert right after the agent is treated as disconnected.

The documentation example contains both settings with default values:

```xml
<global>
  <agents_disconnection_time>15m</agents_disconnection_time>
  <agents_disconnection_alert_time>0</agents_disconnection_alert_time>
</global>
```

The documentation also shows single-value examples: `<agents_disconnection_time>1m</agents_disconnection_time>` and `<agents_disconnection_alert_time>1h</agents_disconnection_alert_time>`. The second value means an alert one hour after the agent is treated as disconnected.

## Intervals on the agent side

`notify_time` in the agent `<client>` block is the number of seconds between agent check-ins with the manager. The default is `20`. More frequent check-ins speed up the distribution of an updated `agent.conf`, but with many agents they can overload the manager.

`time-reconnect` is the number of seconds before a reconnection attempt. The default is `60`. The documentation gives an example: with `notify_time` equal to 60 and `time-reconnect` equal to 300, the agent checks in once a minute. After a failed check-in it waits five minutes before the next attempt, and after a successful connection it returns to the one-minute interval.

```xml
<client>
  <!-- Values from the documentation example: check in every minute, retry after five minutes -->
  <notify_time>60</notify_time>
  <time-reconnect>300</time-reconnect>
</client>
```

## Default values on a timeline

| Step | Parameter | Side | Default value |
| --- | --- | --- | --- |
| Agent check-in | `notify_time` | Agent | 20 s |
| Retry after a failed check-in | `time-reconnect` | Agent | 60 s |
| Agent treated as disconnected since the last keepalive | `agents_disconnection_time` | Manager | 15m |
| Alert from the moment of being treated as disconnected | `agents_disconnection_alert_time` | Manager | 0s |
| Minimum window to an alert with default values | Value given in the documentation | Manager | 15m |

Relations required by the documentation: `notify_time` smaller than `agents_disconnection_time`, and `time-reconnect` greater than `notify_time`.

## Status in the dashboard, CLI and API

In the Wazuh dashboard, the Agents management > Summary view shows the Endpoints list with each agent status and the counters `Active`, `Disconnected`, `Pending` and `Never connected`.

On the Wazuh server, `/var/ossec/bin/agent_control -i` shows the status of one agent, and `/var/ossec/bin/agent_control -l` lists all agents:

```bash
# Status of one agent, for example "Status:     Active"
/var/ossec/bin/agent_control -i <WAZUH_AGENT_ID> | grep Status

# All agents with their status
/var/ossec/bin/agent_control -l
```

The Wazuh server API returns agent statistics:

```text
GET /agents/<WAZUH_AGENT_ID>/stats/agent
```

| Response field | Example in the documentation |
| --- | --- |
| `status` | `connected` |
| `last_keepalive` | Timestamp |
| `last_ack` | Timestamp |
| `msg_count` | Number |
| `msg_sent` | Number |
| `msg_buffer` | Number |
| `buffer_enabled` | `true` |

The agent event buffer and the anti-flooding mechanism are covered in the article on the [agent buffer](/en/blog/wazuh-client-buffer/).

## Local agent state file

The agent writes its own view of the connection to a state file. The file is created when the agent first connects to the manager and is updated every 5 seconds by default. The `agent.state_interval` value in the internal configuration file changes the interval.

| System | State file | Agent log |
| --- | --- | --- |
| Linux | `/var/ossec/var/run/wazuh-agentd.state` | `/var/ossec/logs/ossec.log` |
| Windows | `C:\Program Files (x86)\ossec-agent\wazuh-agent.state` | `C:\Program Files (x86)\ossec-agent\ossec.log` |
| macOS | `/Library/Ossec/var/run/wazuh-agentd.state` | `/Library/Ossec/logs/ossec.log` |

Field descriptions from the state file documentation:

| Field | Meaning |
| --- | --- |
| `status` | `pending`, `connected` or `disconnected` |
| `last_keepalive` | Last keepalive sent |
| `last_ack` | Last control message received |
| `msg_count` | Number of events generated |
| `msg_sent` | Number of messages (events and control messages) sent to the manager |
| `msg_buffer` | Number of events in the buffer, empty when anti-flooding is disabled |

The agent connection page describes the status values like this: `pending` is waiting for connection confirmation from the manager, `disconnected` is no confirmation in the last 60 seconds or a lost connection, and `connected` is a received confirmation. A comment in the example state file describes `connected` as a connection to the manager established in the last 10 seconds. Reading it on Linux:

```bash
sudo grep ^status /var/ossec/var/run/wazuh-agentd.state
# status='connected'
```

## Network connectivity and groups

The agent needs an outbound connection to the manager, by default on port 1514/TCP. The documentation gives a check command for each system:

```bash
# Linux
netstat -vatunp|grep wazuh-agentd

# macOS
lsof -i -P | grep ESTABLISHED | grep 1514
```

```powershell
# Windows
Get-NetTCPConnection -RemotePort 1514
```

Group configuration synchronization is checked with `agent_groups` or the API. The documentation example for agent `001`:

```bash
/var/ossec/bin/agent_groups -S -i 001
# Agent '001' is synchronized.
```

```text
GET /agents?agents_list=001&select=group_config_status
```

The API response contains `"group_config_status": "synced"`. The procedure for adding agents itself is covered in the article on [agent enrollment](/en/blog/wazuh-agent-enrollment/).

## Agent data in `wazuh-db`

According to the documentation, the Wazuh core uses list-based databases to store information about agent keys and FIM and Rootcheck event data. Each agent has a database named after the ID under which it is registered on the manager. The daemon accepts the options `-d` (debug), `-dd` (verbose debug), `-f` (run in the foreground), `-h`, `-V` and `-t` (configuration test).

The agent database tables are `fim_entry`, `sync_info`, `scan_info`, `metadata`, `pm_event` and the Syscollector tables. A separate `tasks` table stores tasks.

- `sync_info` describes synchronization between the agent and manager databases. Fields: `component` (for example `fim`), `last_attempt`, `last_completion`, `n_attempts`, `n_completions`.
- `metadata` stores key and value pairs, for example `db_version`. Keys can also be `last_vacuum_time` and `last_vacuum_value`, the fragmentation left after the last vacuum.
- `pm_event` stores Rootcheck results, one row per distinct result. When a result repeats, `date_last` is updated, and `date_first` holds the time the result was first reported.

| Syscollector table | Contents according to the documentation |
| --- | --- |
| `sys_hwinfo` | System hardware |
| `sys_netiface` | Network interfaces |
| `sys_netaddr` | IPv4 and IPv6 addresses of interfaces |
| `sys_netproto` | Routing configuration for each interface |
| `sys_osinfo` | Operating system |
| `sys_ports` | Open ports |
| `sys_processes` | Running processes |
| `sys_programs` | Installed packages |
| `sys_hotfixes` | Windows updates installed on the agent |
| `sys_users` | User accounts |
| `sys_groups` | User account groups |
| `sys_services` | Services |
| `sys_browser_extensions` | Browser extensions |

The `<wdb>` block in `ossec.conf` configures the global database backup. The `backup` option takes a `database` attribute with the only allowed value `global`. `enabled` defaults to `yes`, `interval` to `1d` (units `s`, `m`, `h`, `d`), and `max_files` to `3`. After `max_files` is exceeded, the oldest file is deleted. The documentation example makes a copy of `global.db` once a day and keeps at most three files:

```xml
<wdb>
  <backup database='global'>
    <enabled>yes</enabled>
    <interval>1d</interval>
    <max_files>3</max_files>
  </backup>
</wdb>
```

## What the documentation does not specify

The documentation gives no rule ID or alert text for the alert triggered by `agents_disconnection_alert_time`. It gives no paths for the global database, agent databases or backups. It does not describe what happens to agent data in `wazuh-db` while the agent is disconnected. Beyond the requirement that `notify_time` be smaller than `agents_disconnection_time`, it does not explain the exact relation between a check-in and a keepalive. It also does not link the 60 and 10 second thresholds from the local state file to the manager threshold, and it gives no rule that derives the cause of a disconnection from `last_keepalive` and `last_ack`.

## Sources

- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/global.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/client.html
- https://documentation.wazuh.com/current/user-manual/agent/agent-management/agent-connection.html
- https://documentation.wazuh.com/current/user-manual/agent/agent-enrollment/agent-life-cycle.html
- https://documentation.wazuh.com/current/user-manual/reference/statistics-files/wazuh-agentd-state.html
- https://documentation.wazuh.com/current/user-manual/reference/daemons/wazuh-db.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/wazuh-db-config.html
