Skip to content
Microsoft SQL Server

SQL Server Error 983

Unable to access availability database because the replica is not PRIMARY or SECONDARY

Severity 14 High Availability
Applies to: SQL Server 2016 to 2025 with Always On availability groups
Last technically reviewed 24 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
Unable to access availability database 'SalesDb' because the database replica is not in the PRIMARY or SECONDARY role. Connections to an availability database is permitted only when the database replica is in the PRIMARY or SECONDARY role. Try the operation again later.
Other forms of this message
SQL Server error log form, when failed logins are logged (from Microsoft documentation)
Logon Error: 983, Severity: 14, State: 1.
Logon Unable to access availability database 'SalesDb' because the database replica is not in the PRIMARY or SECONDARY role. Connections to an availability database is permitted only when the database replica is in the PRIMARY or SECONDARY role. Try the operation again later.
Error number
983
Severity
14 (user-correctable error)
State
1
Product
Microsoft SQL Server Database Engine
Versions
SQL Server 2016 to 2025 with Always On availability groups
Last reviewed
24 October 2026

What it means

Error 983 means the availability group replica you reached is in the RESOLVING role, typically during a failover or a health event, so none of its availability databases can be used until it becomes primary or secondary again.

A replica can use its availability databases only as PRIMARY (read and write) or SECONDARY (read if allowed). When Always On or the Windows Server Failover Cluster detects a health problem, the replica and its databases move to the RESOLVING role and the databases go offline until the availability group comes online again on this or the partner replica. Any connection or USE during that window gets 983 at level 14. The name in quotes is the database.

Microsoft notes that the resolving period during a normal failover usually lasts a few seconds or less, so a retry often succeeds. If 983 persists, the group cannot settle on a primary: typically the cluster has lost quorum, the automatic failover partner is not synchronised, the failover limit for the period was reached, or the SQL Server service on the primary is not healthy.

Common causes

  • A failover is in progress (automatic after a health event, or manual), and the connection arrived during the short resolving window.
  • The Windows Server Failover Cluster lost quorum, so the availability group role cannot come online on any node.
  • An automatic failover could not complete, for example because the partner replica was not synchronised or the cluster failover limit was reached, leaving the replicas resolving.
  • A lease timeout or health check timeout on the primary (high CPU, memory pressure, a memory dump being written) took the group offline.

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.

Which role and state does each replica report?

SELECT ag.name AS ag_name, ar.replica_server_name, rs.role_desc, rs.operational_state_desc,
       rs.connected_state_desc, rs.recovery_health_desc, rs.synchronization_health_desc
FROM sys.availability_replicas AS ar
JOIN sys.availability_groups AS ag ON ag.group_id = ar.group_id
LEFT JOIN sys.dm_hadr_availability_replica_states AS rs ON rs.replica_id = ar.replica_id;
What to look for

RESOLVING confirms the cause. If one replica shows PRIMARY with ONLINE, connect through the listener and retry; if all are resolving, look at quorum and the cluster next.

Does the cluster have quorum?

SELECT cluster_name, quorum_type_desc, quorum_state_desc
FROM sys.dm_hadr_cluster;
What to look for

NORMAL_QUORUM is healthy. NO_QUORUM means the cluster cannot bring the availability group online anywhere until quorum is restored. No row means this instance is not part of a cluster.

Which cluster members and votes are up?

SELECT member_name, member_type_desc, member_state_desc, number_of_quorum_votes
FROM sys.dm_hadr_cluster_members;
What to look for

Nodes or a witness that are DOWN explain lost quorum. Count the votes of the members that are UP against the total.

Were the databases synchronised for automatic failover?

SELECT DB_NAME(drs.database_id) AS database_name, ar.replica_server_name, ar.failover_mode_desc,
       drs.synchronization_state_desc, drs.database_state_desc, drs.is_suspended
FROM sys.dm_hadr_database_replica_states AS drs
JOIN sys.availability_replicas AS ar ON ar.replica_id = drs.replica_id;
What to look for

Automatic failover needs the partner to be SYNCHRONIZED. A partner that was SYNCHRONIZING or suspended explains why the group could not fail over by itself.

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.

Retry through the listener

Client or network side

During a normal failover the resolving window is short. Connect through the availability group listener with MultiSubnetFailover=True and add retry logic with a short delay, so the application reconnects to the new primary on its own.

Server=tcp:SalesAgListener,1433;Database=SalesDb;Integrated Security=true;MultiSubnetFailover=True;ConnectRetryCount=3;ConnectRetryInterval=10

Find and fix why the group cannot come online

Read-only

If 983 persists, read the cluster log and the SQL Server error log of the replicas around the time it started. Lost quorum, a lease or health check timeout, or a stopped service each have their own fix; restore quorum (bring nodes or the witness back) first when the cluster reports NO_QUORUM.

Force a failover only as a last resort

Changes database state

If the primary cannot be recovered in time and the business accepts possible data loss, a forced failover brings a secondary online as the new primary. Run it on the target secondary replica.

Caution: FORCE_FAILOVER_ALLOW_DATA_LOSS can lose committed transactions that had not reached the secondary, and suspends data movement on the other secondaries. Follow the Microsoft forced failover procedure and agree it with the data owner.

ALTER AVAILABILITY GROUP SalesAg FORCE_FAILOVER_ALLOW_DATA_LOSS;

Examples

Using a database while the replica is resolving

Shown as documented by Microsoft; not reproduced here because it needs an availability group during a failover or health event. Microsoft documents state 1 for the error log entry; the query window form was not observed, so no header is shown.

-- Connected to SQL01 while the availability group is failing over
USE SalesDb;
Result
Unable to access availability database 'SalesDb' because the database replica is not in the PRIMARY or SECONDARY role. Connections to an availability database is permitted only when the database replica is in the PRIMARY or SECONDARY role. Try the operation again later.

How to prevent it

Make applications resilient to short failovers: connect through the listener, use MultiSubnetFailover=True and retry on transient errors. Design the cluster quorum (witness, votes) so that losing one node or one site does not take the whole group offline, and alert on replica role changes and on NO_QUORUM.

Keep automatic failover partners synchronised and watch for lease and health check timeouts, which usually come from resource pressure on the primary.

Common questions

How long does the RESOLVING state last?

In a normal failover usually a few seconds or less, according to Microsoft. If it lasts minutes, the group cannot come online anywhere, often because of lost quorum or a failed automatic failover.

How is 983 different from 976?

976 is a secondary that does not allow reads: the replica is healthy but not readable. 983 is a replica that is neither primary nor secondary at the moment, so nothing can use the database.

Can I bring the database online with ALTER DATABASE SET ONLINE?

No. The availability group decides the database state. Fix quorum or the failover, or as a last resort force a failover; changing the database directly does not work while it is in the group.

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.