---
title: "SQL Server mirrored database is stuck in recovery mode"  
description: "SQL Server mirrored database is stuck in recovery mode"  
author: "Jayden Bell"  
published: 2015-09-11  
updated: 2015-09-11  
canonical: https://www.mindstick.com/forum/33458/sql-server-mirrored-database-is-stuck-in-recovery-mode  
category: "mssql server"  
tags: ["database", "mssql server"]  
reading_time: 2 minutes  

---

# SQL Server mirrored database is stuck in recovery mode

I have a [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) that is stuck in [recovery mode](https://answers.mindstick.com/qa/50474/what-to-do-before-restoring-your-iphone-x-in-itunes-recovery-mode-dfu-mode) for few days already. There are [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) threads about this, but the [solutions](https://www.mindstick.com/articles/12807/product-searching-issues-and-solutions-for-ecommerce-store-advanced-search-autocomplete-suggest) there don't work for me.\
Here is what I tried already:

```
RESTORE DATABASE [DBNAME] WITH RECOVERY Error: Exclusive access could not be obtained because the database is in use.ALTER DATABASE [DBNAME] SET OFFLINE WITH ROLLBACK IMMEDIATEError: ALTER DATABASE failed because a lock could not be placed on database 'DBNAME'  I get the same error when trying to set the db to SINGLE_USERexec sp_who2 --> nothing that contains my database, so nothing that I can kill  (Or I need to look for something else ??)
```

I can't just stop the SQL-[service](https://www.mindstick.com/articles/105963/online-thesis-writing-service-for-college-kids-with-disabilities), because it contains too many [databases](https://www.mindstick.com/startup/34/airbyte-the-open-source-platform-simplifying-data-integration-for-warehouses-lakes-and-databases) that can't go down.\
Who knows what I can do to get the database out of recovery mode? At both the primary and mirror [location](https://www.mindstick.com/blog/11636/relocating-business-or-office-to-another-location) is the database state 'In recovery'.\
UPDATEI found a process in sp_who2 with command DB STARTUP.\
At sys.dm_tran_locks, I see this [session](https://www.mindstick.com/articles/12042/session-in-c-sharp) has a resource_database_id for the database that is in recovery, so this keeps the database locked. Anyone knows how to fix this without stopping [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server)?

## Replies

### Reply by Anonymous User

Restart the db mirroring end point:\
--To stop ALTER ENDPOINT<Endpoint Name> STATE=STOPPED\
--To startALTER ENDPOINT<Endpoint Name> STATE=STARTED


---

Original Source: https://www.mindstick.com/forum/33458/sql-server-mirrored-database-is-stuck-in-recovery-mode

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
