Skip to content

Est. 2011ยทMicrosoft Partner ID 7033487ยทDelivery under 3 minยทSupport 7 days a week

Your vault is empty.

License Error 18752

Error 18752: Only One Log Reader Agent Can Connect to the Database

11 min read Updated October 5, 2026 SQL Server

Fix it now

Error 18752 is a lock, not corruption. Its published text says only one Log Reader Agent or log-related procedure can connect to a database at a time, and it prints the session id holding the context. Drop that connection, or run sp_replflush over it, before starting the agent again.

Run the first on the connection that holds the context; the second at the Distributor

EXEC sp_replflush;

SELECT id, name, publisher_db, publication
FROM distribution.dbo.MSlogreader_agents;
  1. Read the 18752 message properly. It names the session id over which a log-related procedure was executed, and dropping that connection or running sp_replflush over it is the documented fix.
  2. If the session belongs to somebody, ask them to run EXEC sp_replflush; in that same query window and then close it. Running it in a fresh window does nothing, which is why it is so often reported as not working.
  3. If the session is abandoned, end it with KILL <session_id>; using the id from the message, then start the Log Reader Agent job.
  4. If the error alternates with successful runs you have two agents. The second query lists one row per Log Reader Agent at this Distributor; look for more than one naming the same publisher database.

The message names four procedures that share this context: sp_repldone, sp_replcmds and sp_replshowcmds take it, and sp_replflush hands it back. Any of the first three run by hand locks the agent out.

If the agent runs and delivers commands, stop here. If the context will not clear, the next section covers the other three ways this happens.

Why it happens

Transactional replication does not copy data. It reads the publisher’s transaction log. When a table is published the engine marks its log records as pending replication, and they stay pending until something reads them and says so. The Log Reader Agent pulls each batch of marked commands, writes them into the distribution database, then marks the log replicated so it can be truncated.

The engine tracks that reading position once per database and lets exactly one session own it. That is what 18752 defends, and the published message is unusually helpful: it names the three procedures that take the context, tells you that sp_replflush releases it, and prints the session id you need to deal with. Most of the advice circulating about this error is a worse version of what the message already says.

The second route to 18752 is a duplicate. Restoring a published database onto another server without stripping its replication metadata, scripting an agent job twice, or rebuilding a distributor while old jobs stay enabled leaves two agents on one database. Both take turns losing, so the job history alternates between success and failure on a regular cycle rather than failing solidly.

The codes that appear beside it are a mixed set. Error 913 is published as being unable to find a database by id, with the note that the database may not be activated yet or may be in transition; in replication that is nearly always the distribution database. Error 21074 is published as subscriptions having been marked inactive and needing reinitialisation, with NoSync subscriptions needing to be dropped and recreated, which is a subscription problem rather than a distributor registration problem. Error 22037 has no published text at all: it appears at the end of Microsoft’s quoted Log Reader Agent error stacks, and that is the only thing anyone can say about it honestly.

An interactive session still owns the log reader context

You have this one if Failures began after somebody ran a replication procedure in a query window, and the agent fails on its first attempt every time.

  1. Take the session id from the 18752 message rather than hunting for it.
  2. Ask that connection’s owner to run EXEC sp_replflush; in the same window, then close it.
  3. If the connection is abandoned, release it with KILL <session_id>; and start the agent job.

sp_replflush only releases the context held by the connection that runs it. In a fresh query window it does nothing at all.

Two Log Reader Agents point at the same database

You have this one if Job history alternates between success and 18752 on a regular cycle, and two agent jobs name the same publisher database.

  1. List the agents at the Distributor and look for more than one row per publisher database.
  2. Stop both jobs and confirm neither still shows as running in Replication Monitor.
  3. Delete the duplicate, keep the job whose history you recognise, and watch the survivor for a few cycles.

There is one Log Reader Agent per published database, not per publication. A restored copy of a published database carries its replication metadata with it, which is the usual source of the second one.

A previous agent process died without releasing the context

You have this one if No duplicate job exists and no user session is connected, but the error survives stopping and starting the job.

  1. Stop the job and wait for it to report Stopped rather than Stopping.
  2. On the machine running the agent, look for an orphaned log reader process for that publication and end it.
  3. If the context still will not clear, restart the SQL Server service on the publisher in a maintenance window to reset the per-database context.

A restart works but is blunt. Exhaust the session-level options first, because a restart hides the cause and the problem returns.

The distributor is missing, offline or misregistered

You have this one if The agent fails before doing useful work and the messages point at the distribution database. Error 913 appears in the same step output.

  1. On the publisher, confirm which distributor and distribution database this publisher is using.
  2. On the distributor, confirm the distribution database is online with SELECT name, state_desc FROM sys.databases WHERE name = 'distribution';
  3. If the distribution database was dropped, reconfigure distribution and recreate the publication and subscriptions.

Full reference

What the message is telling you, line by line

Part of the message What to do with it
“Only one Log Reader Agent or log-related procedure … can connect” Confirms this is a lock, not damage
“sp_repldone, sp_replcmds, and sp_replshowcmds” The three procedures that take the context
“drop the connection with session ID <n>” The session to kill, given to you directly
“or execute sp_replflush over that connection” The polite alternative, on that connection only

Stripping replication metadata from a restored copy

A database restored from a published original still believes it is published, which is how a second Log Reader Agent appears against a database nobody meant to publish. The documented procedure to clean that up is sp_removedbreplication, which takes the database name and a type of tran, merge or both.

Microsoft states that this procedure should be used only if other methods of removing replication objects have failed. It requires membership of the sysadmin fixed server role and cannot be run against a database marked read-only. Remove replication through the normal route first, and keep this for the copy that has no normal route left.

Objects worth knowing

Object What it gives you
distribution.dbo.MSlogreader_agents One row per Log Reader Agent running at the local Distributor, with the publisher database, the publication and the job id
EXEC sp_replflush; Releases the log reader context held by the current connection
EXEC sp_removedbreplication 'db'; Last-resort removal of replication objects from a database
SELECT name, log_reuse_wait_desc FROM sys.databases; Whether replication is the reason the log will not truncate

Why the log grows while this is happening

Truncation waits for replication. Commands stay marked in the publisher’s log until a reader collects them and marks them replicated, so a Log Reader Agent that cannot start means a log that cannot be reused, and on a busy publisher that becomes the more urgent problem within hours. Watch the log reuse wait description rather than the file size, because it tells you whether replication is genuinely the blocker or whether something else is holding the log as well.

Do not switch the database to the simple recovery model or run sp_repldone with reset parameters to control the log size. Both discard pending commands permanently and leave the subscriber silently short of data. Fix the reader instead.

Subscriptions that went inactive while you were fixing this

If the publisher was blocked long enough, you may find error 21074 waiting for you afterwards: subscriptions marked inactive and needing reinitialisation, with NoSync subscriptions having to be dropped and recreated. That is a separate piece of work from clearing the lock, and it is worth checking for before you declare the incident over.

When a licence is the actual fix

Clearing 18752 costs nothing, and every cause above is configuration. Two licensing questions sit close to it, though. SQL Server Express can be a replication subscriber but not a transactional publisher or distributor, so publishing from Express is not a configuration problem to solve. And where publisher, distributor and subscriber all share one machine because that is the only licensed instance available, moving the distributor onto its own instance removes most of the contention behind these conflicts. That instance is licensed like any other, typically SQL Server 2025 Standard (2-core pack) sized to its cores. Arco can check which SKU covers the topology you want before you commit to it.

Every code this article covers

Code What it points at Source
18752 Only one Log Reader Agent or log-related procedure – sp_repldone, sp_replcmds, sp_replshowcmds – can connect to a database at a time; the message names the session id to drop or run sp_replflush over Microsoft Learn
21074 The subscriptions have been marked inactive and must be reinitialised; NoSync subscriptions need to be dropped and recreated Microsoft Learn
913 Could not find the database by id; it may not be activated yet or may be in transition. In replication this is usually the distribution database Microsoft Learn
22037 Appears at the end of Microsoft’s documented Log Reader Agent error stacks alongside the outer and inner codes. No message text is published for it, so read the codes it accompanies not published by the vendor

Confirm the fix worked

  1. The Log Reader Agent job completes cleanly and its history shows commands delivered rather than a startup failure.
  2. Only one row in MSlogreader_agents names that publisher database.
  3. log_reuse_wait_desc no longer sits at REPLICATION, and the log stops growing after the next log backup.
  4. A tracer token posted from Replication Monitor reaches the subscriber within your expected latency.
  5. No subscription is sitting inactive after the incident.

Questions people ask about this

Have I lost data while this error was firing?

No. Commands stay marked in the publisher’s log until a reader collects them, which is exactly why the log will not truncate. Once the agent runs cleanly it resumes where it stopped.

Why is my transaction log growing so fast?

Truncation waits for replication. Check log_reuse_wait_desc in sys.databases; while the reader is stuck it reads REPLICATION. Do not switch to simple recovery or reset with sp_repldone to control the size, because both discard pending commands.

I ran sp_replflush and nothing happened. Why?

Because it only releases the context held by the connection that runs it. If you opened a new query window to run it, it had nothing to release. Run it on the session the 18752 message names, or kill that session.

Do I have to buy anything to resolve 18752?

Almost never. This is configuration and everything here is free. The only real licensing angles are that Express cannot publish, and that some sites want a separate distributor instance.

Can I just restart SQL Server every time it happens?

It usually clears it, and it treats a symptom. If a duplicate agent or a scripted maintenance job keeps taking the context, it returns on the same schedule.

Related error codes

Was this article helpful?

Your feedback helps us improve our documentation.

Related articles

Free Fix Error 9001: The Log for the Database Is Not Available After a Crash Free Fix Error 19407: The Availability Group Lease Expired and Failover Fires License Error Error 3624 Assertion Failures: When a Cumulative Update Is the Only Fix License Error Error 33111: Cannot Find Server Certificate When Restoring a TDE Backup
โ† Back to Knowledge Base