Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 1431: Partner/Witness Fix

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server error 1431 means the database mirroring session cannot find either the mirror partner or the witness server, so the principal database cannot form a quorum and may become unavailable. The direct fix is to restore network connectivity and confirm the mirroring endpoints are running, then resume the mirroring session. This guide walks you through the checks and steps to get mirroring back online.

What You'll Need

  • Access to SQL Server Management Studio (SSMS) on the principal server, and ideally on the mirror and witness servers.
  • Permission to run T-SQL queries and view SQL Server error logs (sysadmin or equivalent).
  • The names of the principal, mirror, and witness server instances, and the database name.
  • Network access between the servers (ports 5022 or the custom mirroring port, plus the SQL Server browser port if using named instances).
  • Windows Firewall or network security group rules that allow the mirroring traffic.

Step-by-Step

  1. Check the SQL Server error log on the principal server. Open SSMS, connect to the principal instance, and run EXEC sp_readerrorlog; or navigate to Management > SQL Server Logs. Look for messages around error 1431 that name the partner or witness and indicate a connection timeout or login failure. This tells you which side is unreachable.
  2. Verify the mirroring endpoints are started. On each server (principal, mirror, witness), run:
    SELECT name, state_desc, role_desc, type_desc FROM sys.database_mirroring_endpoints;
    The state_desc should be STARTED. If it is STOPPED, start it with ALTER ENDPOINT <endpoint_name> STATE = STARTED;.
  3. Test network connectivity between all three servers. From the principal, use ping <mirror_server> and ping <witness_server>. Then test the mirroring port with telnet <server> 5022 (or use Test-NetConnection -ComputerName <server> -Port 5022 in PowerShell). Repeat from the mirror and witness if possible. If any test fails, fix the network path or firewall rule before continuing.
  4. Confirm the endpoint accounts have connect permission. The SQL Server service account on each instance must be able to authenticate to the others. Check that the endpoint uses the correct authentication (Windows or certificate) and that the login exists on the remote instance. For Windows authentication, ensure the service accounts are domain accounts or have matching local accounts with the same password.
  5. Check the mirroring state on the principal. Run:
    SELECT DB_NAME(database_id) AS DatabaseName, mirroring_state_desc, mirroring_role_desc, mirroring_partner_name, mirroring_witness_name FROM sys.database_mirroring WHERE mirroring_guid IS NOT NULL;
    If mirroring_state_desc is DISCONNECTED or SUSPENDED, note the partner and witness names and verify they match the actual server names.
  6. Restart the SQL Server service on the affected instance if the endpoint is unresponsive. A service restart can clear a stuck endpoint. Plan this during a maintenance window; restarting the principal may cause a brief outage.
  7. Resume the mirroring session. On the principal, run:
    ALTER DATABASE <database_name> SET PARTNER RESUME;
    If the session was suspended, this attempts to reconnect. If it fails, check the error log again for the specific reason.
  8. If the witness is the problem, reconfigure it. Remove the witness with ALTER DATABASE <database_name> SET WITNESS OFF; then add it back with ALTER DATABASE <database_name> SET WITNESS = 'TCP://<witness_server>:5022';. Ensure the witness database is the same database and is in the correct state.
  9. Verify the session is synchronized. Run the query from step 5 again. The mirroring_state_desc should be SYNCHRONIZED (or SYNCHRONIZING while catching up). Also check mirroring_safety_level_desc to confirm high safety if that is your configuration.

Common Mistakes

  • Forgetting to open the mirroring port in Windows Firewall on all three servers.
  • Using the wrong server name in the partner or witness address (for example, a short name instead of a fully qualified domain name when required).
  • Assuming the witness is optional; in high-safety mode with automatic failover, the witness is required for quorum.
  • Not checking that the mirror database is in the RESTORING state before resuming.
  • Restarting the SQL Server service on the principal without warning users, causing unnecessary downtime.

Tips

  • Use fully qualified domain names (FQDN) in the partner and witness addresses to avoid name resolution issues.
  • Keep a record of the exact endpoint URLs and port numbers for each server.
  • Monitor mirroring state with a scheduled query or SQL Server Agent alert to catch disconnections early.
  • If you use certificates for endpoint authentication, ensure they have not expired and are present on all instances.
  • Test failover in a non-production environment to understand the behavior when the witness is unavailable.

Troubleshooting

If the steps above do not resolve error 1431, work through these checks:

  • Error log details: Look for messages about login failed for the endpoint account, or about the partner being unable to connect. The specific error (e.g., 18456, 1418) points to the cause.
  • Endpoint permissions: Run SELECT * FROM sys.database_mirroring_endpoints; and verify the role_desc and connection_auth_desc. For Windows authentication, the service account must have CONNECT permission on the endpoint. Grant it with GRANT CONNECT ON ENDPOINT::<endpoint_name> TO [<domain\account>];.
  • Certificate issues: If using certificates, check that the certificate on each server is valid and that the remote certificate is installed. Use SELECT * FROM sys.certificates; to inspect.
  • DNS resolution: From each server, run nslookup <other_server> to confirm the name resolves to the correct IP address.
  • Service account changes: If the SQL Server service account was changed, the endpoint may need to be recreated or the new account granted permission.
  • Quorum loss: If the witness is down and the mirror is also unreachable, the principal may be unable to serve the database. In that case, you may need to force service on the principal with ALTER DATABASE <database_name> SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS; (use with caution; this may cause data loss).

Frequently Asked Questions

What does error 1431 mean exactly?

It means the principal server cannot connect to either the mirror partner or the witness server, so the mirroring session cannot establish a quorum. The database may become inaccessible until connectivity is restored.

Can I ignore error 1431 if the database is still online?

No. If the principal cannot reach the mirror or witness, it may lose the ability to fail over and could become unavailable. Address the connectivity issue promptly.

Do I need a witness server for database mirroring?

A witness is required only for high-safety mode with automatic failover. In high-performance mode, no witness is needed, but error 1431 can still occur if the mirror is unreachable.

How do I check if the mirroring endpoint is running?

Query sys.database_mirroring_endpoints and check the state_desc column. It should be STARTED. If not, start it with ALTER ENDPOINT.

What port does database mirroring use?

By default, the mirroring endpoint uses TCP port 5022, but it can be configured to a different port. Check the endpoint definition with SELECT * FROM sys.tcp_endpoints;.

Can error 1431 cause data loss?

Not directly, but if you are forced to force service on the principal, any transactions that were not mirrored may be lost. Always attempt to restore connectivity first.