423 Locked
HTTP response status code 423 Locked is a client error that is returned by the server to indicate that the target file or folder is locked.
Usage
The 423 Locked error message is part of WebDAV, used as a file system over HTTP. Clients have the option to LOCK or UNLOCK files and if a client attempts to modify a locked resource, this is the error that is returned by the server.
When a lock is first granted by a server, the Lock-Token
response header is sent to the client, which can be used to later unlock the resource or refresh the lock.
As part of the response, the server will include an appropriate precondition or post-condition code to help guide the client. This might include lock-token-submitted
or no-conflicting-lock
.
Note
Search engines like Google will not index a URL with 423 Locked response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.
Example
In the example, the client attempts to upload a file to the target folder. However, it is currently locked. The operation is not allowed and the 423 Locked error message is returned. In the subsequent request, the client asks that the resource be unlocked by including the Lock-Token
as part of the If request header.
In the example, the request is successful because there was only one lock on the folder at the time. However, it is relevant to consider that a successful UNLOCK only means that the lock referred to by the specified Lock-Token
has been removed. Other locks can still be in use, and once again return the 423 Locked status.
Initial request
PUT /documents/ HTTP/1.1
Host: www.example.re
Content-Type: applications/pdf
Content-Length: 10000
<PDF file transferred>
Initial response
HTTP/1.1 423 Locked
Content-Type: application/xml
Content-Length: 163
<?xml version="1.0" encoding="utf-8" ?>
<d:error xmlns:d="DAV:">
<d:lock-token-submitted>
<d:href>/documents/</d:href>
</d:lock-token-submitted>
</d:error>
Second request, incorporating unlock request
PUT /documents/ HTTP/1.1
Host: www.example.re
Content-Type: applications/pdf
Content-Length: 10000
If: (<urn:uuid:123…789>)
<PDF file transferred>
Final response
HTTP/1.1 204 No Content
Code references
.NET
HttpStatusCode.Locked
Rust
http::StatusCode::LOCKED
Rails
:locked
Go
http.StatusLocked
Symfony
Response::HTTP_LOCKED
Python3.5+
http.HTTPStatus.LOCKED
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_LOCKED
Angular
@angular/common/http/HttpStatusCode.Locked
Takeaway
The 423 Locked status code is a client error generated by the server when conflicting access is required to a locked resource. The client can try again when the resource is unlocked. The client may be capable of unlocking it, or the lock timer may expire, if applicable.