Fix it now
Two different things carry the number 20011. In agent output it is the outer line, and Microsoft’s example is “The process could not execute sp_replcmds” with the real error carried underneath it. As an engine message it is about incompatible publication properties. Error 20084 is published as a publication that cannot be subscribed to by a given Subscriber database.
SELECT TOP 50 time, error_code, error_text
FROM distribution.dbo.MSrepl_errors
ORDER BY time DESC;
- Open Replication Monitor, find the failing agent and open its history. The detail pane shows the inner error underneath the outer 20011 line, and that inner error is what you fix.
- Note which agent it is and where it runs: a push Distribution Agent runs at the Distributor, a pull one at the Subscriber, and the Log Reader Agent at the Distributor.
- Look at that agent’s job step and note two identities: the account the process runs under, and the account it uses to connect to each replication partner. They are configured separately and either can be the problem.
- Test that connection by hand from the machine where the agent runs, using the same account, then correct whichever identity is wrong and start the agent again.
Do not spend time on the outer number. Microsoft’s own examples show 20011 carried alongside inner codes such as 18805, 18836, 3624 and 22037, and it is those that name the fault.
If the agent completes and its history is clean, stop here. If it fails the same way, the next section covers the two identities every agent has.
Why it happens
Every replication agent is an executable started by a SQL Server Agent job. It has a process account, which is the identity the job step runs as, and one or more connection accounts, which are the credentials it uses to reach the Publisher, the Distributor and the Subscriber. The two are configured separately, and either one can be the reason a connection is refused.
That is why the outer error is so unhelpful on its own. In Microsoft’s Log Reader Agent troubleshooting, every quoted failure has the same shape: an outer line with code 20011 and the text “The process could not execute sp_replcmds”, then an inner code that names the actual fault, then 22037 at the end of the stack. The inner codes in those examples include 18805 and 18836 for a command the reader could not construct, and 3624 for an assertion. Reading only the outer number tells you nothing that the word “failed” does not.
There is a second thing to know about these numbers, and it explains a lot of contradictory advice. The number in agent output is not the same as the engine message with the same number. Microsoft’s published message for 20011 is about incompatible publication properties, specifically that a publication’s allow_anonymous property depends on its immediate_sync property. Its published message for 20084 is that a publication cannot be subscribed to by a named Subscriber database. If you meet either number in a query window rather than in agent history, that is what it means.
Errors 14150 and 14151 are the outcome messages the agent job writes when it finishes: “Replication-<agent type>: agent <name> succeeded” and “…failed”, both followed by the detail. They are useful for reading a sequence of runs and seeing exactly when things stopped working, and they never contain the cause on their own.
The process account lacks rights at the Distributor
You have this one if The agent fails immediately on every run, and the inner error is about permissions rather than about reaching a server.
- Confirm the account the job step runs under is a member of the db_owner fixed database role in the distribution database, which is the documented requirement for every agent that connects to the Distributor.
- For the Snapshot Agent, confirm the same account has read, write and modify permissions on the snapshot share, using its UNC path rather than a local one.
- Restart the agent job and read the first entries in its history rather than the job outcome.
The connection account is not in the publication access list
You have this one if The agent starts, reaches the Publisher or Distributor and is refused, and the inner error names a login.
- Add the account the agent connects with to the publication access list for that publication.
- For a Distribution Agent, confirm it also has db_owner on the subscription database at the Subscriber.
- Retest by running the agent job rather than by connecting interactively, since only the job reproduces the real context.
A stored password is out of date
You have this one if Everything worked until an account’s password was rotated, and the inner error is a login failure for that account.
- Update the credentials on the subscription or agent through Replication Monitor or the subscription properties dialog, which is the least error-prone route.
- Check every agent that used the same account, since one rotation usually breaks several at once.
- If the account is also the SQL Server or Agent service account, change it in SQL Server Configuration Manager as well, or the next restart will fail too.
The partner cannot be reached
You have this one if A connection timeout underneath the outer error, and the partner is a named instance, behind a firewall, or on a different network.
- From the machine where the agent runs, test the path to the partner on the port it uses, adjusting for a non-default port.
- For a named instance, confirm the SQL Server Browser service is running, or configure a fixed port and an alias.
- Confirm the partner instance is running and its database is online rather than in recovery.
A server was renamed and the recorded names no longer match
You have this one if Errors began after a rename or a restore onto a differently named instance.
- Compare
SELECT @@SERVERNAME;on each machine with whatEXEC sp_helpserver;records. - Correct the recorded local name with
sp_dropserverandsp_addserver, then restart the instance and Agent. - Expect to remove and reconfigure replication, because renaming a computer involved in replication is documented as unsupported.
Full reference
Two identities per agent, and which one to look at
| Agent | Runs where | Documented minimum access |
|---|---|---|
| Snapshot Agent | Where you configured it | db_owner on the distribution database, and read, write and modify on the snapshot share |
| Log Reader Agent | At the Distributor | db_owner on the distribution database and on the publication database |
| Distribution Agent, push | At the Distributor | db_owner on the distribution database, publication access list membership, read on the snapshot share, and db_owner on the subscription database |
| Distribution Agent, pull | At the Subscriber | db_owner on the subscription database and on the distribution database, publication access list membership, read on the snapshot share |
| Merge Agent | Push at the Distributor, pull at the Subscriber | db_owner on the relevant databases, publication access list membership, read on the snapshot share |
Reading the agent history
| What the history shows | Where to look |
|---|---|
| An outer 20011 wrapping a login failure | The connection account: password, mapping or publication access list |
| An outer line with a timeout underneath | The network path to that partner: name, port, instance state |
| Failure started after a password change | A stored credential still holds the old password |
| Failure started after a server rename | The recorded server names no longer match the instances |
| Only the Snapshot Agent fails | Permissions on the snapshot share rather than in a database |
| 18805, 18836 or 3624 inside the stack | A command the Log Reader could not construct, or an assertion; a different investigation |
Reading the errors without Replication Monitor
- The distribution database records agent errors, so you can reconstruct a failure from a query window.
- The agent jobs keep their step history in msdb, which is where the 14150 and 14151 outcome messages land.
- Between the two you can see exactly when a sequence of successful runs turned into failures, which usually points at the change that caused it.
- Keep enough history to cover a rotation cycle, because the commonest cause of a sudden failure is a password change nobody associated with replication.
Windows authentication and the extra hop
An agent that connects successfully when you test it interactively and fails when the job runs it is usually a delegation problem rather than a replication one. The supported ways out are to configure the agent to connect to that partner with SQL Server authentication, which avoids delegation entirely, or to work through service principal names and constrained delegation with the domain team. Retest by running the agent job, since only the job reproduces the real context.
Removing and rebuilding replication is disruptive: subscriptions are dropped, new snapshots are applied and subscribers are unavailable while that happens. Plan it as a maintenance activity with the application owners rather than running the removal procedures to see whether they help.
Every code this article covers
| Code | What it points at | Source |
|---|---|---|
20011 |
In agent output, the outer line on a failed agent – Microsoft’s example is “The process could not execute sp_replcmds” – with the real cause in the inner error. As an engine message it reports incompatible publication properties, where allow_anonymous depends on immediate_sync | Microsoft Learn |
20084 |
The publication cannot be subscribed to by the named Subscriber database | Microsoft Learn |
14151 |
Replication: the named agent failed, followed by the detail | Microsoft Learn |
14150 |
Replication: the named agent succeeded, followed by the detail | Microsoft Learn |
Confirm the fix worked
- The failing agent job runs to completion by hand with no error.
- The agent history shows recent runs succeeding rather than retrying.
- A change at the Publisher reaches the Subscriber within the latency you expect.
- The agent still runs correctly after a restart of the instance it runs on.
- The account each agent uses is documented somewhere, so the next password rotation is planned rather than discovered.
Questions people ask about this
Why does the outer error never say anything useful?
Because it is the agent reporting that it failed and passing the underlying error along. Microsoft’s own examples show the outer 20011 line carried with inner codes such as 18805, 18836, 3624 and 22037, and those are where the diagnosis is.
Does fixing this cost anything?
No. These failures are accounts, permissions and network paths, all free to correct. No licence or edition affects whether an agent can authenticate.
Should agents use Windows or SQL Server authentication?
Windows authentication is preferable for the process account. For the connection to a partner across a trust boundary, SQL Server authentication is often simpler and avoids delegation problems, which is why it is a common configuration.
I got 20084 in a query window rather than from an agent. What does it mean there?
Its published text is that the publication cannot be subscribed to by that Subscriber database. Check the publication’s properties and the subscription you are trying to create rather than looking for a network problem.
Can I see the errors without Replication Monitor?
Yes. The distribution database records agent history and errors in its own tables, and the agent jobs keep their step history in msdb. Between them you can reconstruct what happened without the graphical tool.
