Skip to content
Cloudflare Docs

Error codes

This page documents error codes returned by R2 when using the Workers API or the S3-compatible API, along with recommended fixes to help with troubleshooting.

How errors are returned

For the Workers API, R2 operations throw exceptions that you can catch. The error code is included at the end of the message property:

JavaScript
try {
await env.MY_BUCKET.put("my-key", data, { customMetadata: largeMetadata });
} catch (error) {
console.error(error.message);
// "put: Your metadata headers exceed the maximum allowed metadata size. (10012)"
}

For the S3-compatible API, errors are returned as XML in the response body:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>

Error code reference

Authentication and authorization errors

Error CodeS3 CodeHTTP StatusDetailsRecommended Fix
10002Unauthorized401Missing or invalid authentication credentials.Verify your API token or access key credentials are correct and have not expired.
10003AccessDenied403Insufficient permissions for the requested operation.Check that your API token has the required permissions for the bucket and operation.
10018ExpiredRequest400Presigned URL or request signature has expired.Regenerate the presigned URL or signature.
10035SignatureDoesNotMatch403Request signature does not match calculated signature.Verify your secret key and signing algorithm. Check for URL encoding issues.
10042NotEntitled403Account not entitled to this feature.Ensure your account has an R2 subscription.

Bucket errors

Error CodeS3 CodeHTTP StatusDetailsRecommended Fix
10005InvalidBucketName400Bucket name does not meet naming requirements.Bucket names must be 3-63 chars, lowercase alphanumeric and hyphens, start/end with alphanumeric.
10006NoSuchBucket404The specified bucket does not exist.Verify the bucket name is correct and the bucket exists in your account.
10008BucketNotEmpty409Cannot delete bucket that contains objects.Delete all objects in the bucket before deleting the bucket.
10009TooManyBuckets400Account bucket limit exceeded (default: 1,000,000 buckets).Request a limit increase via the Limits Increase Request Form.
10073BucketConflict409Bucket name already exists.Choose a different bucket name. Bucket names must be unique within your account.

Object errors

Error CodeS3 CodeHTTP StatusDetailsRecommended Fix
10007NoSuchKey404The specified object key does not exist. For the Workers API, get() and head() return null instead of throwing.Verify the object key is correct and the object has not been deleted.
10020InvalidObjectName400Object key contains invalid characters or is too long.Use valid UTF-8 characters. Maximum key length is 1024 bytes.
100100EntityTooLarge400Object exceeds maximum size (5 GiB for single upload, 5 TiB for multipart).Use multipart upload for objects larger than 5 GiB. Maximum object size is 5 TiB.
10012MetadataTooLarge400Custom metadata exceeds the 8,192 byte limit.Reduce custom metadata size. Maximum is 8,192 bytes total for all custom metadata.
10069ObjectLockedByBucketPolicy403Object is protected by a bucket lock rule and cannot be modified or deleted.Wait for the retention period to expire. Refer to bucket locks.

Upload and request errors

Error CodeS3 CodeHTTP StatusDetailsRecommended Fix
10033MissingContentLength411Content-Length header required but missing.Include the Content-Length header in PUT/POST requests.
10013IncompleteBody400Request body terminated before expected Content-Length.Ensure the full request body is sent. Check for network interruptions or client timeouts.
10014InvalidDigest400Checksum header format is malformed.Ensure checksums are properly encoded (base64 for SHA/CRC checksums).
10037BadDigest400Provided checksum does not match the uploaded content.Verify data integrity and retry the upload.
10039InvalidRange416Requested byte range is not satisfiable.Ensure the range start is less than object size. Check Range header format.
10031PreconditionFailed412Conditional headers (If-Match, If-Unmodified-Since, etc.) were not satisfied.Object's ETag or modification time does not match your condition. Refetch and retry. Refer to conditional operations.

Multipart upload errors

Error CodeS3 CodeHTTP StatusDetailsRecommended Fix
10011EntityTooSmall400Multipart part is below minimum size (5 MiB), except for the last part.Ensure each part (except the last) is at least 5 MiB.
10024NoSuchUpload404Multipart upload does not exist or was aborted.Verify the uploadId is correct. By default, incomplete multipart uploads expire after 7 days. Refer to object lifecycles.
10025InvalidPart400One or more parts could not be found when completing the upload.Verify each part was uploaded successfully and use the exact ETag returned from UploadPart.
10048InvalidPart400All non-trailing parts must have the same size.Ensure all parts except the last have identical sizes. R2 requires uniform part sizes for multipart uploads.

Service errors

Error CodeS3 CodeHTTP StatusDetailsRecommended Fix
10001InternalError500An internal error occurred.Retry the request. If persistent, check Cloudflare Status or contact support.
10043ServiceUnavailable503Service is temporarily unavailable.Retry with exponential backoff. Check Cloudflare Status.
10054ClientDisconnect400Client disconnected before request completed.Check network connectivity and retry.
10058TooManyRequests429Rate limit exceeded. Often caused by multiple concurrent requests to the same object key (limit: 1 write/second per key).Check if multiple clients are accessing the same object key. See R2 limits.