# Azure Service Bus: MessageLockLostException — The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue

**Code:** `MessageLockLost` · **Category:** Azure · **Seen on:** Azure

A message was completed or abandoned after its lock expired.

## Meaning

In peek-lock mode a message is locked for a limited time (default 30 seconds up to 5 minutes). Slow processing lets the lock lapse so the message becomes visible again and the late `Complete` fails.

## Common causes

- Processing longer than the lock duration
- Lock not renewed
- Message already completed or dead-lettered
- Connection dropped

## Quick fix

1. Enable automatic lock renewal (`MaxAutoLockRenewalDuration`)
2. Increase the lock duration on the queue
3. Make handlers idempotent since messages can be redelivered

## Detailed fix by platform

### .NET

1. `new ServiceBusProcessorOptions { MaxAutoLockRenewalDuration = TimeSpan.FromMinutes(10) }`

## How to diagnose

1. **Time** — Processing vs lock?
2. **Renew** — Auto renewal?
3. **Idempotent** — Duplicates handled?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/azure/azure-servicebus-message-lock-lost)
