SQL Server Error 1415: Database Mirroring Fix
In this article
Error 1415 means the mirroring operation for that database failed, and the shortest working fix is to check the mirroring state on both partners, confirm the endpoints are started and reachable, verify the mirror database is restoring (not recovered), and then resume or re-establish the session from the principal. The error is a generic wrapper: SQL Server raises it when the specific mirroring action (pause, resume, failover, or setup) cannot complete, and the real cause is in the SQL Server error log and the mirroring monitor on both servers. Work through the checks below in order, because most 1415 failures come down to one of four things: a stopped endpoint, a database in the wrong recovery state, a principal and mirror that disagree about the session, or a network or authentication problem between the two instances.
What You'll Need
- Sysadmin or db_owner rights on both the principal and mirror instances, plus permission to run ALTER DATABASE and ALTER ENDPOINT.
- The SQL Server error log on both partners, read around the timestamp of the failure.
- The mirroring monitor or the sys.database_mirroring and sys.database_mirroring_endpoints views for the current state.
- A working connection between the two instances on the mirroring port (usually 5022) and matching service account or certificate authentication.
- A current backup of the principal database before you change any mirroring setting.
Step-by-Step
- Read the actual error. Connect to the principal and run SELECT * FROM sys.database_mirroring WHERE database_id = DB_ID('YourDatabase'); then do the same on the mirror. Look at mirroring_state_desc, mirroring_role_desc and mirroring_safety_level_desc. Error 1415 is almost always accompanied by a more specific message in the error log, such as "The mirroring connection to ... has timed out" or "The database ... is not configured for database mirroring." Fix the specific message, not the wrapper.
- Check the mirroring endpoints. On each instance run SELECT name, role_desc, state_desc, port FROM sys.database_mirroring_endpoints; The state_desc must be STARTED. If it is STOPPED, run ALTER ENDPOINT [Mirroring] STATE = STARTED; If no endpoint exists, create one with CREATE ENDPOINT [Mirroring] STATE = STARTED AS TCP (LISTENER_PORT = 5022) FOR DATABASE_MIRRORING (ROLE = PARTNER); (use ROLE = WITNESS on a witness if you run one).
- Confirm the mirror database is in RESTORING. On the mirror, run SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabase'; It must show RESTORING. If it shows ONLINE or RECOVERY_PENDING, the mirror copy was recovered by mistake. Restore the full and log backups again WITH NORECOVERY, then re-run the mirroring setup.
- Check connectivity and authentication. From the principal, test the port with Test-NetConnection MirrorServer -Port 5022 in PowerShell, and confirm the SQL Server service accounts can authenticate to each other (domain accounts, or certificates if the instances are in different domains or workgroups). A firewall blocking 5022 produces a timeout that surfaces as 1415.
- Resume a paused session. If mirroring_state_desc shows SUSPENDED, run ALTER DATABASE YourDatabase SET PARTNER RESUME; on the principal. If the mirror is the one that paused, run the same command there.
- Re-establish a broken session. If the session is DISCONNECTED, first try ALTER DATABASE YourDatabase SET PARTNER RESUME; then, if that fails, re-point the partners. On the mirror run ALTER DATABASE YourDatabase SET PARTNER = 'TCP://PrincipalServer:5022'; and on the principal run ALTER DATABASE YourDatabase SET PARTNER = 'TCP://MirrorServer:5022'; Run the mirror-side command first, then the principal-side command.
- Verify the fix. Re-run the sys.database_mirroring query on both sides. You want mirroring_state_desc = SYNCHRONIZED (high safety) or SYNCHRONIZING, with matching role descriptions. Then open the mirroring monitor and confirm the log send queue and redo queue are draining.
Common Mistakes
- Treating 1415 as the root cause. It is a wrapper; the specific error in the log is what you act on.
- Running the principal-side SET PARTNER command before the mirror-side one during re-setup. The mirror must be pointed at the principal first.
- Restoring the mirror database WITH RECOVERY. That takes it out of RESTORING and mirroring cannot start.
- Forgetting that the mirror database name must match the principal database name, and that the mirror must be restored from a full backup plus all subsequent log backups WITH NORECOVERY.
- Opening port 5022 on one server but not the other, or allowing it only for the wrong service account.
- Changing the safety level (high safety vs. asynchronous) mid-troubleshooting without recording the original setting.
Tips
- Capture the output of sys.database_mirroring and sys.database_mirroring_endpoints from both partners before and after any change so you can see what actually moved.
- Use the mirroring monitor (right-click the database in Object Explorer > Tasks > Mirroring, or the Mirroring Monitor under the database) to watch the log send queue and redo queue in real time.
- Keep the principal and mirror on the same SQL Server major version and the same collation; mismatches cause setup failures that look like 1415.
- If you use certificates for authentication, confirm both certificates are current and the logins exist on both instances.
- Test failover only during a maintenance window, and confirm the application connection string uses a failover partner or an availability group listener.
Troubleshooting
If the session still will not come up, work from the outside in. First, confirm the SQL Server service is running on both partners and that the error log shows no endpoint or login failures at the time you ran the command. Second, check that the mirror database is still in RESTORING after your changes; if it flipped to RECOVERY_PENDING, re-restore it WITH NORECOVERY. Third, verify the partner addresses in the SET PARTNER commands match the actual server names and ports, and that DNS resolves them from both sides. Fourth, if authentication is the problem, switch to certificate-based authentication or ensure the service accounts are domain accounts with logins on both instances. Fifth, if the session is stuck in a SUSPENDED or DISCONNECTED state that will not clear, remove mirroring with ALTER DATABASE YourDatabase SET PARTNER OFF; on both sides (this deletes the mirroring configuration, not the data), then rebuild the mirror from a fresh full backup and log backups WITH NORECOVERY. Take a backup first, and note that SET PARTNER OFF ends the session and the mirror database becomes unusable until it is restored again.
If none of that clears the error, collect the full error log from both partners, the output of the sys.database_mirroring queries, and the exact command that failed, and open a support case with Microsoft; the specific companion error in the log is what support will need.
Frequently Asked Questions
What does SQL Server error 1415 actually mean?
It is a generic message that the requested database mirroring operation failed. The real cause is in the accompanying error log entry, so always read that first.
Can I fix 1415 without restarting SQL Server?
Yes. Most cases are fixed by starting a stopped endpoint, resuming a suspended session, or re-pointing the partners with SET PARTNER. A service restart is rarely needed and should be a last resort.
Why does the mirror database need to be in RESTORING?
Mirroring applies log records continuously to the mirror, so the mirror must be in RESTORING (WITH NORECOVERY). If it is recovered, it cannot accept more log and the session will not start.
Does SET PARTNER OFF delete my data?
No. It removes the mirroring configuration from the database. The principal keeps its data, but the mirror database is left in a state that requires a fresh restore before it can be used again.
What port does database mirroring use?
The endpoint port is whatever you configure, commonly 5022. Check it with the sys.database_mirroring_endpoints query and make sure the same port is open on both servers.
Can I use mirroring with a witness for automatic failover?
Yes, with high-safety mode and a witness instance. The witness must be reachable from both partners, and all three endpoints must be started for automatic failover to work.