Skip to content
Microsoft SQL Server

SQL Server Error 14258

Cannot perform this operation while SQL Server Agent is starting

Severity 16 SQL Server Agent
Applies to: SQL Server editions that include SQL Server Agent (2016 to 2025), Azure SQL Managed Instance
Last technically reviewed 24 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
Cannot perform this operation while SQL Server Agent is starting. Try again later.
Other forms of this message
Older wording (Microsoft Learn error list)
Cannot perform this operation while SQLServerAgent is starting. Try again later.
Error number
14258
Severity
16 (user-correctable error)
State
Not documented by Microsoft (not reproduced here)
Product
Microsoft SQL Server Database Engine
Versions
SQL Server editions that include SQL Server Agent (2016 to 2025), Azure SQL Managed Instance
Last reviewed
24 October 2026

What it means

Error 14258 means a job or alert procedure in msdb was called while the SQL Server Agent service was still starting up, so msdb refused the change until Agent has finished starting.

While SQL Server Agent starts, it reads its jobs, schedules and alerts from msdb into memory. To keep that picture consistent, the msdb procedures that look up or change a job (sp_start_job, sp_update_job, sp_delete_job, sp_add_jobstep and others) and the alert procedures first ask whether Agent is starting (msdb.dbo.sp_is_sqlagent_starting). If it is, they raise 14258 and make no change.

The condition is normally short, so the message itself says to try again later. If it repeats for minutes, Agent is not finishing its start: it may be stuck or failing and restarting, and its own log tells you why. 14258 is different from error 22022, which means Agent is not running at all.

Common causes

  • A script or deployment pipeline runs job procedures straight after the server or the Agent service was restarted, during the short startup window.
  • A failover of a failover cluster instance or a server reboot: Agent starts after the Database Engine, and early jobs or scripts hit the window.
  • SQL Server Agent takes a long time to start, for example with a very large job history or many jobs, alerts and schedules to load.
  • Agent fails while starting and is restarted repeatedly, so it seems to be starting most of the time.

Diagnose it

Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.

What is the state of the SQL Server Agent service?

SELECT servicename, status_desc, startup_type_desc, last_startup_time, service_account
FROM sys.dm_server_services
WHERE servicename LIKE N'SQL Server Agent%';
What to look for

Start pending or a Running service with a very recent last_startup_time fits 14258. Check again after a minute: it should be Running.

Have the Agent sessions connected yet?

SELECT session_id, program_name, login_time, status
FROM sys.dm_exec_sessions
WHERE program_name LIKE N'SQLAgent%'
ORDER BY login_time;
What to look for

Once Agent is fully up you see sessions such as SQLAgent - Generic Refresher and SQLAgent - Job invocation engine. Login times that keep moving forward suggest Agent is restarting.

How often has SQL Server Agent started recently?

SELECT TOP (10) session_id, agent_start_date
FROM msdb.dbo.syssessions
ORDER BY agent_start_date DESC;
What to look for

Each Agent start adds a row. Many starts a few minutes apart point to a restart loop: read the Agent log (SQLAGENT.OUT, or EXEC sys.sp_readerrorlog 0, 2;) for the error that stops it.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Wait and retry

Client or network side

The message asks you to try again later, and that is the right first step. In scripts that run after a restart, retry a few times with a delay instead of failing on the first attempt.

DECLARE @try int = 1, @rc int = 1;
WHILE @try <= 5 AND @rc <> 0
BEGIN
    EXEC @rc = msdb.dbo.sp_start_job @job_name = N'Nightly ETL';
    IF @rc <> 0 WAITFOR DELAY '00:00:30';
    SET @try += 1;
END;

Make deployment steps wait for Agent

Client or network side

In post-restart or deployment scripts, check that the Agent service is Running and that its sessions are connected (the first two diagnostics) before calling job procedures.

Fix an Agent that does not finish starting

Changes configuration

If 14258 persists, read the Agent log and the Windows event log for the start failure, such as a service account problem or msdb not being available, and fix that cause. If startup is slow because of a very large job history, trim it with the history retention settings in SQL Server Agent properties.

Caution: Trimming job history deletes rows from msdb that you may need for audits or troubleshooting; agree the retention period first.

Examples

Updating a job right after SQL Server Agent was restarted

Shown as documented by Microsoft (message text); not reproduced here because it needs SQL Server Agent to be starting. No state or header is shown because none was observed. The text is raised by msdb.dbo.sp_is_sqlagent_starting, which the job procedures call. The job name is an example.

EXEC msdb.dbo.sp_update_job @job_name = N'Nightly ETL', @enabled = 1;
Result
Cannot perform this operation while SQL Server Agent is starting. Try again later.

How to prevent it

Schedule deployments and scripts that change Agent jobs away from restarts, and give post-restart automation an explicit wait for SQL Server Agent to be running. Keep job history within sensible limits so Agent starts quickly, and monitor the Agent log for failed starts so a restart loop is noticed early.

Common questions

How long does SQL Server Agent stay in the starting state?

Usually only seconds. Microsoft gives no fixed duration; if the error lasts minutes, check the Agent log, because Agent is probably failing to start or restarting.

Was my job change saved?

No. The check runs before the procedure changes anything, so run the same call again once Agent is running.

Does 14258 mean SQL Server Agent is stopped?

No. A stopped Agent gives error 22022 when you start a job. 14258 means Agent is on its way up.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 24 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.