Dmitry,
The error you are seeing:
2026/02/18 10:15:05 wazuh-agent: ERROR: Duplicate agent name: AppSRV. Unable to add agent (from manager)
means that the Wazuh manager already has an agent registered with the name AppSRV. Even if Windows was reinstalled, and the client.keys file was cleared on the server, but the manager still detects a duplicate agent name during enrollment.
In Wazuh, agent names must be unique. It is not possible to rename an agent after it has been enrolled. The agent name is defined only during the enrollment process. If another agent with the same name already exists in the manager database, enrollment will fail with the duplicate name error.
To resolve this issue, you need to re-enroll the agent using a different name.
You can define the agent name during installation or enrollment using the deployment variable: WAZUH_AGENT_NAME
https://documentation.wazuh.com/current/user-manual/agent/agent-enrollment/deployment-variables/index.html
For example, during installation on Windows, set the variable so the agent registers with a unique name instead of AppSRV.
Alternatively, you can define the agent name in the ossec.conf file on the Windows agent before starting the service.
Edit: C:\Program Files (x86)\ossec-agent\ossec.conf
Add the following block:
<enrollment>
<agent_name>YOUR_NEW_AGENT_NAME/agent_name>
</enrollment>
Reference:
https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/client.html#enrollment
After saving the file, start the Wazuh agent service. The agent will request a new key from the manager and register with the new name.
Please note that when you re-enroll the agent with a new name, it will receive a new agent ID and a new key. Any previous association with the old agent entry will not be preserved.
If you still encounter issues, please confirm whether there is still an existing agent entry with the name AppSRV on the manager by running on the manager:
/var/ossec/bin/agent_control -l
If AppSRV is still listed, you can remove it before re-enrollment using:
/var/ossec/bin/manage_agents -r <WAZUH_AGENT_ID>
https://documentation.wazuh.com/current/user-manual/agent/agent-management/remove-agents/remove.html
Then delete the old entry and enroll the agent again with a unique name.
This will ensure the duplicate name conflict is fully resolved.
Based on the logs, the problem is that the endpoint is still using an old client key, which belongs to agent ID 022.
On the manager, you removed the agent, but the Windows endpoint still has its previous client.keys content. Because of that, the agent continues using the old key, and the manager reports:
Agent key already in use: agent ID '022' Duplicate name 'APPSRV2026', rejecting enrollment. Agent '022' can't be replaced since it is not disconnected.To fully fix the issue, the agent must be removed and reinstalled on the endpoint, not only removed from the manager.
Please do the following on the Windows system:
Uninstall the Wazuh agent completely
Install the agent again
Before starting the service, define the new agent name in ossec.conf:
<enrollment>
<agent_name>APPSRV2026</agent_name>
</enrollment>
or set it via WAZUH_AGENT_NAME during installation.
When the agent is reinstalled, it will generate a new client.key, and the manager will accept it.
If reinstalling does not resolve it, please share:
I can then reproduce the issue on my side.
It seems that no events are being discarded, and the issue is caused by older agent entries still existing on the manager with the same client key or agent name.
Uninstall the Wazuh agent from the Windows system completely using:
msiexec.exe /x wazuh-agent-4.14.3-1.msi /qn
Remove the corresponding agent entry from the Wazuh manager, including any duplicate or previously connected entries:
/var/ossec/bin/manage_agents -r <WAZUH_AGENT_ID>
Restart the Wazuh manager and confirm that no old agent ID remains.
Then, verify on the Windows endpoint that no old Wazuh files or configurations are left.
Reinstall the Wazuh agent on the Windows endpoint with a unique agent name. You can set it directly in the configuration:
or by using the installation variable:
If there is still a connection issue, check the manager database to see if any leftover records exist:
sqlite3 /var/ossec/queue/db/global.db
SELECT id, name, register_ip FROM agent;
--
You received this message because you are subscribed to a topic in the Google Groups "Wazuh | Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wazuh/SlCrtPHCoyA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wazuh+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wazuh/1abda69e-536e-409c-b5a8-bb9d695e4f9en%40googlegroups.com.