423 Locked: Resource Is Locked (WebDAV)
How Locking Works in WebDAV
WebDAV (Web Distributed Authoring and Versioning) extends HTTP to support collaborative editing. It uses:
- LOCK โ to lock a resource, preventing others from modifying it.
- UNLOCK โ to release the lock.
- Lock tokens โ unique identifiers that represent the lock, passed in the
Ifheader to prove ownership.
If a client tries to PUT, POST, or DELETE a resource that is locked by another client, the server returns 423 Locked.
Common Causes of 423 Errors
| Cause | Example | How to Fix |
|---|---|---|
| Resource locked by another user | Another client holds a lock on the resource. | Wait for the lock to be released or contact the user who holds the lock. |
| Stale lock not released | Previous user crashed without releasing the lock. | Use a lock manager to forcibly release stale locks, or implement timeouts. |
| Client lacks lock token | Client tries to modify but doesn't include the lock token in the If header. | Obtain the lock token and include it in the request. |
| Server misconfiguration | Server lock management is broken. | Fix server configuration or implement proper locking logic. |
Example: 423 Response
A client attempts to PUT a file that is locked by another user:
How to Fix 423 Errors
- If you're a client: Check if you hold the lock. If not, obtain the lock token via LOCK and include it in the
Ifheader. If you are the lock owner but don't have the token, you may need to unlock and reโlock. - If you're a server developer: Implement proper lock management. Use timeouts to automatically release stale locks. Send clear error messages that include the lock owner and token.
- If you're an endโuser: This error is rare outside WebDAV clients (e.g., Microsoft Office, file managers). Contact the person who locked the file or your system administrator.
Related WebDAV Codes
- 207 Multi-Status โ used for batch operations.
- 424 Failed Dependency โ used when a previous operation in a batch fails.
- 507 Insufficient Storage โ server out of space.
Frequently Asked Questions
Is 423 a client error or a server error?
It's a client error (4xx) because the client's request cannot be fulfilled due to the resource being locked. However, the lock is a serverโside state, so it's a conflict between the client's intention and the server's current state.
Can I use 423 outside of WebDAV?
Technically yes, but it's designed for WebDAV. In REST APIs, you might use 409 Conflict or 422 Unprocessable Entity for similar cases (e.g., resource being edited).
What is a lock token?
A lock token is a unique identifier (usually a URI) that represents a specific lock. It is used to prove ownership of the lock when performing operations on the locked resource.