SQL Server Error 1499: Database Mirroring Fix
In this article
SQL Server error 1499 is a database mirroring error that occurs when a mirroring session cannot be established or maintained because the principal and mirror databases are not in a state that allows the partnership. The error message includes status, severity, and state values that point to the specific cause. The fix is to check the mirroring endpoint, verify the database states, and re-establish the mirroring session after correcting the underlying issue. No special tools are required beyond SQL Server Management Studio (SSMS) and access to both server instances.
What You'll Need
- SQL Server Management Studio (SSMS) connected to both the principal and mirror server instances with sysadmin or db_owner permissions.
- The database name and the mirroring endpoint names for both instances.
- Network connectivity between the principal and mirror servers on the mirroring port (default 5022).
- A recent backup of the principal database in case you need to restore or reinitialize the mirror.
Step-by-Step
- Read the full error message. Error 1499 includes status, severity, and state values. Note them down. The state value often indicates whether the issue is with the endpoint, the database state, or the mirroring partner configuration. For example, state 1 often means the database is not configured for mirroring, while state 2 may indicate the mirror database is not in the restoring state.
- Check the mirroring endpoint on both servers. In SSMS, connect to each instance and run:
SELECT name, role_desc, state_desc, connection_auth_desc, encryption_algorithm_desc FROM sys.database_mirroring_endpoints;
Ensure the endpoint exists, is started, and uses the same authentication (usually Windows or certificate). If the endpoint is missing, create it with:CREATE ENDPOINT MirroringEndpoint STATE = STARTED AS TCP (LISTENER_PORT = 5022) FOR DATABASE_MIRRORING (ROLE = PARTNER);
Replace the port if you use a different one. The endpoint name can differ; just be consistent. - Verify the database state on the principal. Run:
SELECT name, state_desc, mirroring_state_desc, mirroring_role_desc FROM sys.databases WHERE name = 'YourDB';
The principal should show ONLINE and mirroring_state_desc as SYNCHRONIZING or SYNCHRONIZED. If mirroring_state_desc is SUSPENDED or NULL, mirroring is not active. - Verify the database state on the mirror. Connect to the mirror instance and run the same query. The mirror database should be in RESTORING state. If it is ONLINE or RECOVERING, you must restore it with NORECOVERY. To do this, take a full backup of the principal and restore it on the mirror with NORECOVERY, then restore any subsequent log backups with NORECOVERY.
- Check the mirroring partner configuration. On the principal, run:
SELECT mirroring_partner_name, mirroring_partner_instance, mirroring_witness_name FROM sys.database_mirroring WHERE database_id = DB_ID('YourDB');
Ensure the partner name and instance are correct and reachable. If they are wrong, you may need to remove and re-add the partner using ALTER DATABASE ... SET PARTNER. - Test network connectivity. From the principal server, use
telnetor5022 Test-NetConnection -ComputerNamein PowerShell. From the mirror, test the principal on the same port. If the connection fails, check firewall rules and SQL Server Browser service if using dynamic ports.-Port 5022 - Re-establish mirroring if needed. If the mirroring session is broken, you may need to remove mirroring and reconfigure. On the principal, run
ALTER DATABASE YourDB SET PARTNER OFF;then on the mirror, restore the latest backups with NORECOVERY. Then on the mirror, set the partner to the principal:ALTER DATABASE YourDB SET PARTNER = 'TCP://PrincipalServer:5022';and on the principal, set the partner to the mirror:ALTER DATABASE YourDB SET PARTNER = 'TCP://MirrorServer:5022';. - Monitor the mirroring monitor. In SSMS, right-click the principal database, choose Tasks > Mirror, and click Start Mirroring if not started. Use the Mirroring Monitor to check status and resolve any warnings.
Common Mistakes
- Restoring the mirror database with RECOVERY instead of NORECOVERY, which makes it online and unusable for mirroring.
- Using mismatched endpoint authentication (one server uses Windows auth, the other certificates).
- Forgetting to open the firewall port for mirroring traffic on both servers.
- Assuming error 1499 always means the endpoint is down; it can also indicate the database is not in the correct state.
- Not taking a fresh backup before reinitializing the mirror, leading to data loss.
Tips
- Always note the state value from the error message; it narrows down the cause quickly.
- Use the same SQL Server version and edition on both partners to avoid compatibility issues.
- Keep the mirroring endpoint port consistent and document it.
- Test failover in a non-production environment before relying on mirroring.
- Monitor mirroring health with SQL Server Agent alerts or the Mirroring Monitor.
Troubleshooting
If error 1499 persists after checking the endpoint and database states, verify that the SQL Server service account on each instance has permission to connect to the other. For Windows authentication, the service accounts must be domain accounts or have matching local accounts with identical passwords. Check the SQL Server error log on both instances for additional error messages around the time of the failure. If the mirroring endpoint is in a STOPPED state, start it with ALTER ENDPOINT MirroringEndpoint STATE = STARTED;. If the database is in a SUSPENDED state, resume mirroring with ALTER DATABASE YourDB SET PARTNER RESUME;. If the mirror database is not in RESTORING state, you must restore it with NORECOVERY from a backup. If the partner is unreachable, check DNS resolution and network routing. In some cases, the error may be caused by a mismatched mirroring safety level (FULL vs OFF); ensure both partners use the same safety level. Finally, if all else fails, remove mirroring and reconfigure from scratch, but only after taking a full backup of the principal database.
Frequently Asked Questions
What does error 1499 mean in SQL Server?
Error 1499 is a database mirroring error indicating that the mirroring session cannot be established or maintained due to an invalid state or configuration on one or both partners. The status, severity, and state values in the message help identify the specific problem.
How do I find the state value for error 1499?
The state value is included in the error message text. You can also check the SQL Server error log or the Windows Event Log for the full message.
Can error 1499 occur if the mirror database is online?
Yes. If the mirror database is not in the RESTORING state, mirroring cannot start. You must restore it with NORECOVERY.
What permissions are needed to fix error 1499?
You need sysadmin or db_owner permissions on both the principal and mirror instances to alter endpoints and database mirroring settings.
Does error 1499 affect high availability?
Yes, if mirroring is not working, the database is not protected by mirroring. Failover will not be possible until the error is resolved.
Can I use certificates instead of Windows authentication for mirroring endpoints?
Yes, but both endpoints must use the same authentication type. If one uses Windows and the other certificates, error 1499 can occur.