423 Locked
The resource that is being accessed is locked, meaning it cannot be modified until the lock is released.
Meaning & Description
Common Causes
- Another user or process holds an active lock on the requested resource.
- The client application failed to include the necessary lock token in the 'If' request header.
- A background synchronization process has temporarily locked the file.
How to fix a 423 error
- Check the response body for WebDAV-specific XML error details indicating the nature of the lock.
- Verify if your client application is correctly parsing and sending the 'If' header with a valid lock token.
- Use a PROPFIND request to inspect the active locks on the resource.
- Wait for the existing lock to expire or contact the user holding the lock.
Browser & SEO Behaviour
Browser Behavior
Browsers generally do not encounter WebDAV status codes during normal web surfing. If they do, they display a generic error page or prompt the user to download an XML error document.
SEO Impact
Search engines do not use WebDAV methods like PUT or LOCK, so they will rarely encounter this code. If a GET request returns 423, it might temporarily impede crawling.
CDN Behavior
CDNs typically pass through WebDAV methods and status codes without caching them, as they deal with stateful resource modification.
Code Examples
PUT /workspace/document.txt HTTP/1.1
Host: api.example.com
Content-Type: text/plain
[Updated content here]app.put('/api/documents/:id', (req, res) => {
const doc = getDocument(req.params.id);
if (doc.isLocked && doc.lockToken !== req.headers['if']) {
return res.status(423).json({ error: "Resource is locked." });
}
// Proceed with update
});@app.put("/api/documents/{doc_id}")
def update_document(doc_id: str, if_header: str = Header(None, alias="If")):
if is_locked(doc_id) and if_header != get_lock_token(doc_id):
raise HTTPException(status_code=423, detail="Resource is locked")
return {"message": "Updated successfully"}func updateHandler(w http.ResponseWriter, r *http.Request) {
ifHeader := r.Header.Get("If")
if resourceIsLocked("doc1") && ifHeader == "" {
http.Error(w, "Resource is locked", 423)
return
}
w.WriteHeader(http.StatusOK)
}[HttpPut("{id}")]
public IActionResult UpdateDocument(string id, [FromHeader(Name = "If")] string lockToken) {
if (DocumentService.IsLocked(id) && lockToken == null) {
return StatusCode(423, "The resource is locked.");
}
return Ok();
}curl -X PUT https://api.example.com/docs/file.txt \
-H "Content-Type: text/plain" \
-d "New content" \
-iRaw HTTP Response Example
HTTP/1.1 423 Locked
Content-Type: application/xml; charset=utf-8
Content-Length: 185
<?xml version="1.0" encoding="utf-8" ?>
<d:error xmlns:d="DAV:">
<d:lock-token-submitted/>
</d:error>Real-world Examples
Frequently Asked Questions
What is the difference between 423 Locked and 403 Forbidden?
403 Forbidden means the client permanently lacks the necessary permissions to perform the action. 423 Locked is a temporary state indicating that the resource is currently checked out or locked by another process, but the client might have permission otherwise.
How do I bypass a 423 Locked error?
You cannot bypass it without the correct lock token. You must either wait for the lock to expire, request the current lock holder to release it via an UNLOCK request, or forcefully break the lock if you have administrative privileges.
Is 423 only used for WebDAV?
Yes, 423 is officially defined as part of the WebDAV specification (RFC 4918). However, some non-WebDAV APIs adopt it informally to indicate that a resource is temporarily frozen or locked.
How long does a lock last?
The duration of a lock depends on the 'Timeout' header provided during the initial LOCK request and the server's configuration. It can be a specific number of seconds or 'Infinite'.
Can I read a locked file?
Yes, WebDAV locks typically apply to write operations (like PUT, POST, DELETE). GET requests usually succeed even if the resource is locked, allowing others to read the current state.
Did You Know?
The 423 status code was introduced in RFC 2518 in 1999 to support distributed authoring on the web.
WebDAV locks are identified by a URI called an 'opaquelocktoken', which is usually a UUID to ensure global uniqueness.
Some APIs use 423 to indicate business-logic locks, such as a frozen bank account, even though it deviates from strict WebDAV semantics.
Developer Tips
- When designing APIs that require concurrency control, consider using ETags and 412 Precondition Failed instead of WebDAV locks for simpler HTTP compliance.
- Always include a meaningful error message in the response body when returning 423, so the client knows who holds the lock or when it expires.
- Implement administrative endpoints to forcefully release stale locks that might block users indefinitely.
- Ensure your WebDAV implementation properly cleans up expired locks via a background job or during subsequent access attempts.
Interview Questions
These are questions you might face in a backend or API design interview that touch on HTTP 423.
What does the HTTP 423 status code indicate and which protocol extension is it part of?
It indicates that the requested resource is locked. It is part of the WebDAV extension to HTTP, which adds concurrency control for document authoring.
How does a client successfully modify a resource that is currently locked?
The client must include a valid lock token in the 'If' header of the modification request (e.g., PUT or DELETE) to prove they own the lock.
Why might a modern REST API choose not to use 423 Locked for concurrency?
Modern APIs often prefer optimistic concurrency control using ETags (returning 412 Precondition Failed) over pessimistic locking (423) because it scales better and avoids issues with abandoned locks.
Common Interview Mistakes
- Confusing 423 Locked with 401 Unauthorized or 403 Forbidden.
- Assuming 423 is a standard HTTP/1.1 code rather than a WebDAV extension.
- Thinking that a locked resource cannot be read (GET requests typically still work).
- Failing to mention the need for a lock token to resolve the lock state.