Fix SignatureDoesNotMatch on browser uploads to S3 and S3-compatible storage: compare signed and sent headers

by Opndrive25 min read
Title card reading: Fix SignatureDoesNotMatch on browser uploads by comparing signed and sent headers
On this page

Your frontend uploads a file to a presigned URL, and the browser gets 403 SignatureDoesNotMatch. The same URL works from curl or from your server. The error means the storage service rebuilt the signature from the request it received, and the result did not match the one in the URL (AWS, Troubleshoot Signature Version 4). So the browser sent a request that your signer did not expect.

This post gives you a short order of checks. First compare what was signed with what the browser sent. Then replay the request with curl. Then fix the one cause the comparison points to. It covers presigned PUT uploads to Amazon S3, Cloudflare R2, Backblaze B2 and MinIO. Presigned POST form uploads use a different scheme, and neither R2 (Cloudflare R2, Presigned URLs) nor B2 (Backblaze B2, S3-Compatible API) supports them.

The commands and the program below come from the documentation linked at each step. None of them were run for this post, so try them on a test bucket first.

In this post:

  • What SignatureDoesNotMatch means on a browser upload
  • The decision order
  • Step 1: compare what was signed with what the browser sent
  • Step 2: replay the request with curl
  • The fixes: Content-Type, SDK checksums, a changed URL, endpoint and region, clock and expiry, the secret key
  • A reference signer and upload script
  • FAQ and a final checklist

What SignatureDoesNotMatch means on a browser upload

SignatureDoesNotMatch means the storage service recomputed the signature from the request it received and got a different value from the one in your presigned URL. It is not a permissions error. On a browser upload, look for a request that differs from what was signed, or a URL signed with the wrong region, endpoint or secret.

The permissions case is a different problem. AWS’s presigned-URL FAQ handles it under its own 403 Forbidden question, apart from the SignatureDoesNotMatch question (AWS, presigned URLs). CORS is a different problem too. A browser upload to another origin usually sends an OPTIONS preflight before the real PUT (MDN, Preflight request), and a failed preflight is a CORS fix, not a signing fix. This post leaves permissions aside and gives only the CORS steps that Fix B needs.

The signature covers the HTTP method, the headers and the query string. AWS says all of them must “match exactly between URL generation and usage” (AWS, presigned URLs). Only host and x-amz-* headers must be signed, and other standard headers such as content-type are optional (AWS, Create a signed request). The same AWS page also says that if the Content-Type header is present in the request, you must add it to the canonical headers, so treat Content-Type as something you sign on purpose. Change any signed part between signing and sending, and the two signatures differ.

The decision order

Work through these steps in order. Each one either finds the cause or rules out a group of causes.

  1. Compare X-Amz-SignedHeaders and the rest of the URL with the PUT the browser sent (step 1 below). If you test on a local emulator, rerun the request on the real endpoint first.
  2. Replay the request with curl, to separate browser problems from signer problems (step 2 below).
  3. Fix by cause: Content-Type, then SDK checksum parameters, an altered URL, endpoint and region, clock and expiry, and last the secret key.

The curl baseline splits the work in two. If it passes, the browser changed the request, so fix Content-Type, then checksum parameters. If it fails too, the signer is wrong, so check the URL, region, clock and keys in that order.

Cause Where you see it Fix
Content-Type differs from the signed one content-type is in X-Amz-SignedHeaders, and the PUT in DevTools sends another value Sign the exact type and send it explicitly
The SDK added checksum parameters x-amz-checksum-crc32 or x-amz-sdk-checksum-algorithm in the query string, JavaScript SDK v3 at 3.729.0 or later requestChecksumCalculation: "WHEN_REQUIRED" on the signing client, or sign the real checksum
The URL changed after signing The path or query in DevTools differs from the generated URL, special characters in the key, a proxy or a custom domain Encode the key once, don’t rewrite the URL, call the host you signed for
Wrong region or endpoint The region in X-Amz-Credential is not the bucket’s region Sign with the bucket’s region and the endpoint the browser calls
Clock skew or an expired URL It fails from every client, curl included Sync the signer’s clock with NTP and sign a fresh URL
The secret doesn’t belong to the access key ID The curl replay and a CLI call with the same keys both fail Re-enter or replace the key pair
An emulator mislabels the error It fails only against a local emulator Test against the real endpoint

Step 1: compare what was signed with what the browser sent

Before you blame your code: are you on an emulator?

If you test against a local emulator, check this first. An open issue on aws/aws-emulator (#51, opened 2026-11-12) reports that, with default auth, the emulator answers a presigned request that carries a browser Origin header with 403 SignatureDoesNotMatch, although the URL signs only host (aws/aws-emulator #51). The reporter notes: “Users then debug keys, clock skew and signing code instead of the browser-origin check.” A second user narrowed it to Origin and Sec-Fetch-Site: cross-site, and wrote that real S3 ignores headers not listed in X-Amz-SignedHeaders. That is the commenter’s statement, not AWS documentation. The emulator’s README says not to use it “to test security” (aws/aws-emulator). Run the same request against the real endpoint before you debug your signing code.

Read the presigned URL

A Signature Version 4 presigned URL carries its signing inputs in the query string. Here is one broken onto lines for reading. Every value is an example: AKIAIOSFODNN7EXAMPLE is AWS’s documentation key ID, and the two checksum lines appear only if your SDK added them.

https://<HOST>/<KEY>
  ?X-Amz-Algorithm=AWS4-HMAC-SHA256
  &X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20261121%2Fus-east-1%2Fs3%2Faws4_request
  &X-Amz-Date=20261121T120000Z
  &X-Amz-Expires=300
  &X-Amz-SignedHeaders=content-type%3Bhost
  &x-amz-checksum-crc32=AAAAAA%3D%3D
  &x-amz-sdk-checksum-algorithm=CRC32
  &X-Amz-Signature=<SIGNATURE>
Part of the URL What it tells you Where it leads
X-Amz-SignedHeaders The header names that were signed: lowercase, sorted, separated by semicolons (AWS, Create a signed request) The comparisons below, and the Content-Type fix
X-Amz-Credential The access key ID, then the date, region, service and aws4_request (AWS, Create a signed request) The region fix and the secret-key fix
X-Amz-Date and X-Amz-Expires When the URL was signed (UTC), and for how many seconds it is valid (AWS, presigned URLs) The clock and expiry fix
x-amz-checksum-crc32, x-amz-sdk-checksum-algorithm Checksum parameters an SDK added The checksum fix
Host and path The hostname and the encoded object key The altered-URL fix

Treat a live presigned URL as a password: anyone who has it can use it until it expires. Don’t paste one into a public issue, and blur the signature and key ID in screenshots.

Find the PUT in DevTools, not the OPTIONS

Open the Network panel and select the failed PUT. Open its Headers tab and scroll to Request Headers (Chrome DevTools, Network features reference). An upload to another origin usually shows an OPTIONS preflight just before it (MDN, Preflight request). Compare the PUT, not the OPTIONS. Then open the Response tab of the PUT to read the error body the service returned.

Make three comparisons

  1. Every name in X-Amz-SignedHeaders appears in Request Headers, with the value the signer used. In practice this is usually the content-type check.
  2. The request URL in DevTools matches the generated URL character for character. AWS’s checklist says to use the URL “exactly as generated, without any modifications” (AWS, Uploading objects with presigned URLs).
  3. No x-amz-* request header appears that the signer never saw. Every x-amz-* header belongs in the signature (AWS, Create a signed request), so check any your code adds after signing.

Some headers are out of your hands. Origin and Host are forbidden request headers, which “cannot be set or modified programmatically in a request” (MDN, Forbidden request header). If a custom signer included one of them, fix the signer, not the frontend.

Step 2: replay the request with curl

A curl replay tells you whether the browser or the signer is at fault. Run two of them.

The first is the baseline. AWS’s upload example sends the file with curl, with the same Content-Type that was used to create the URL, and with the URL in quotes (AWS, Uploading objects with presigned URLs). Add -v to print every header curl sends and receives (Everything curl, Verbose). The placeholders are example values to replace:

Bash
# <PRESIGNED_URL>: the URL your signer returned
# <FILE>: a local test file
# <SIGNED_TYPE>: the Content-Type you passed when signing, for example image/png
URL='<PRESIGNED_URL>'   # single quotes keep the & characters intact
curl -v -X PUT -T '<FILE>' -H 'Content-Type: <SIGNED_TYPE>' "$URL"

The second is the browser’s exact request. In Chrome DevTools, right-click the PUT and copy it as a cURL command (Chrome DevTools, Network features reference). Check that the copied command carries the file. If it doesn’t, add -T '<FILE>' yourself.

Read the results like this:

  • The baseline fails too. The signer, the URL or the keys are wrong, not the browser. Go to the URL, region, clock and secret-key fixes below.
  • The baseline passes and the browser’s copy fails. The browser adds or changes something. Remove the copied headers one at a time until the request passes. The last header you removed is the cause. Start with Content-Type and any x-amz-* header.

Fix a Content-Type that doesn’t match the signature

AWS and Cloudflare both name this cause. AWS’s checklist says to make sure “the content type in your upload request matches the content type specified when generating the URL” (AWS, Uploading objects with presigned URLs). R2’s docs say the signature includes this header, so uploads fail with 403/SignatureDoesNotMatch if the client sends a different Content-Type (Cloudflare R2, Presigned URLs).

The browser takes its value from the file. When the body is a File or Blob whose type is not empty, the Fetch Standard uses that type for the request (Fetch Standard, extract a body). So the header follows file.type, which depends on the file the user picked. Decide the type when you sign, sign it on purpose, and send exactly that value.

In the browser, set the header to the value you signed instead of relying on file.type:

JavaScript
// signedType: the Content-Type your server signed and returned with the URL (example: "image/png")
const res = await fetch(url, {
  method: "PUT",
  headers: { "Content-Type": signedType },
  body: file,
});
if (!res.ok) {
  console.error(`Upload failed: HTTP ${res.status}`, await res.text());
}

On the signer, with the AWS SDK for JavaScript v3, pass ContentType on PutObjectCommand and add content-type to the presigner’s signableHeaders, so the header is enforced (@aws-sdk/s3-request-presigner README). Then sign a URL and check that X-Amz-SignedHeaders lists content-type.

If you sign for R2 with aws4fetch, Cloudflare says to set allHeaders: true so the Content-Type header is signed (Cloudflare R2, Presigned URLs).

Fix checksum parameters the JavaScript SDK added

What changed in SDK 3.729.0

From version 3.729.0, the AWS SDK for JavaScript calculates a CRC32 checksum for uploads by default (AWS SDK for JavaScript v3, S3 checksums). That version was released on 2025-01-15 (v3.729.0 release notes). If uploads broke after you updated @aws-sdk/client-s3, look here.

The setting is requestChecksumCalculation in the JavaScript client config (aws-sdk-js-v3 #6810), request_checksum_calculation in the shared config file, or the AWS_REQUEST_CHECKSUM_CALCULATION environment variable. The default is WHEN_SUPPORTED. With WHEN_REQUIRED, checksums are calculated only when the operation requires one (AWS SDKs and Tools, Data integrity protections).

One report of the failure

Here is what it looked like in one report. In a January 2025 forum post about Tigris storage, a presigned PUT URL from getSignedUrl carried x-amz-checksum-crc32=AAAAAA%3D%3D and x-amz-sdk-checksum-algorithm=CRC32. The PUT got SignatureDoesNotMatch, and requestChecksumCalculation: 'WHEN_REQUIRED' on the client fixed it (Fly.io community forum). That is one practitioner’s report, not vendor documentation.

Our reading of why it fails, not from a cited source: AAAAAA== decodes to four zero bytes, and by our calculation that is the CRC32 of an empty body. A presigned URL is made before the file exists, so this looks like a checksum of nothing, not of the file the browser sends later. AWS also says an upload that uses these checksum algorithms must “include the appropriate checksum header in your upload request” (AWS, presigned URLs). A checksum built into the URL is a condition the browser’s upload then has to meet.

Fix A: turn off default checksums on S3-compatible providers

Set requestChecksumCalculation: "WHEN_REQUIRED" on the client that signs the URL. In the SDK’s announcement thread, users reported that the default change broke R2 and B2. Those are user comments. The maintainers replied that the SDK “is designed to work with AWS services” and pointed users of other services to their provider’s documentation (aws-sdk-js-v3 #6810).

Fix B: keep the integrity check on Amazon S3

The same maintainers “recommend not to disable default data integrity protections with Amazon S3” (aws-sdk-js-v3 #6810). To keep a checksum, compute the file’s SHA-256 in the browser and send it to your server. Sign it on PutObjectCommand, and list its header in the presigner’s unhoistableHeaders, which forces that header to be present in the upload request (@aws-sdk/s3-request-presigner README). A pre-calculated checksum turns off the SDK’s automatic one (AWS SDK for JavaScript v3, S3 checksums). The browser then sends the same value as a header, and the bucket’s CORS rules must allow that header. This flow is untested:

JavaScript
// Server side. checksumBase64 is the Base64 SHA-256 of the file, computed in the browser.
// client, signedType, <BUCKET> and <KEY> are as in the full program further down.
const url = await getSignedUrl(
  client,
  new PutObjectCommand({
    Bucket: "<BUCKET>",
    Key: "<KEY>",
    ContentType: signedType,
    ChecksumSHA256: checksumBase64,
  }),
  {
    expiresIn: 300,
    signableHeaders: new Set(["content-type"]),
    unhoistableHeaders: new Set(["x-amz-checksum-sha256"]),
  },
);

// Browser side: send the same two values as headers.
// headers: { "Content-Type": signedType, "x-amz-checksum-sha256": checksumBase64 }

Check this on your own SDK version. The only presigned PUT evidence above is one forum report from January 2025. The presigner README describes a default of “not hoisting any headers that begin with x-amz-*”, which does not fit that report. Other providers may answer the same problem with a different error code. Sign a URL with your current SDK and look for checksum parameters in it before you pick Fix A or Fix B.

Console steps: allow the upload headers in CORS

The bucket’s CORS rules must list every header the browser’s PUT sends. The browser’s OPTIONS preflight names those headers in Access-Control-Request-Headers (MDN, Preflight request), and a policy that does not allow them refuses the preflight. For Fix B that means Content-Type and x-amz-checksum-sha256.

On Amazon S3, these steps follow AWS, Configuring cross-origin resource sharing (CORS):

  1. Sign in to the AWS Management Console and open the Amazon S3 console.
  2. In the left navigation pane, choose General purpose buckets.
  3. In the buckets list, choose the name of your bucket.
  4. Choose Permissions.
  5. In the Cross-origin resource sharing (CORS) section, choose Edit.
  6. In the CORS configuration editor, enter a JSON configuration. Include PUT in AllowedMethods, your site’s origin in AllowedOrigins, and the two header names above in AllowedHeaders.
  7. Choose Save changes.

On Cloudflare R2, these steps follow Cloudflare R2, Configure CORS:

  1. In the Cloudflare dashboard, go to the R2 object storage page.
  2. Select your bucket.
  3. Open the Settings tab.
  4. Under CORS Policy, choose Add CORS policy.
  5. In the JSON tab, enter the policy with the same three fields.
  6. Choose Save.

On other providers, use that provider’s CORS setting as its documentation describes.

Fix a URL that changed after signing

Key encoding

The signed path encodes every byte except the unreserved characters, and AWS says to encode the forward slash “everywhere except in the object key name” (AWS, Create a signed request). A space must be %20, not + (same page). If the signer encodes the key one way and the request carries it another way, the signatures differ.

For a key that contained =, the SDK maintainers’ answer was to “URI-encode the key parameter”. The reporter’s working fix was to split the key on / and run encodeURIComponent on each segment. A commenter reported that parentheses still failed (aws-sdk-js-v3 discussion #4862).

Self-hosted servers can be strict about encoding. In 2020 a MinIO maintainer closed a case where a client sent an unescaped ; in a presigned query value, and told the reporter to “fix the client code and escape it yourself” (minio/minio #8897). GitHub shows that repository as archived since 2026-04-25, so treat it as a dated answer.

The simplest way out is to generate keys from a safe character set on your server. Keep the user’s original file name in object metadata or your database.

Proxies, gateways and rewritten hosts

AWS warns that “some corporate proxies might modify headers or query strings”, and says to test without the proxy (AWS, presigned URLs). The host header is always signed (AWS, Create a signed request), so a reverse proxy that changes Host or the path breaks the signature.

A MinIO maintainer wrote in 2018 that you “cannot rewrite URLs”, and that the presigned URL should be generated for the address the client uses (minio/minio #6853). Sign with the same public hostname the browser will call.

Cloudflare R2: custom domains and changed parameters

Cloudflare says R2 presigned URLs work with the S3 API domain (<ACCOUNT_ID>.r2.cloudflarestorage.com) “and cannot be used with custom domains” (Cloudflare R2, Presigned URLs). The same page says that modifying “the resource, operation, or expiry” gives 403/SignatureDoesNotMatch. Sign for the S3 API domain, and don’t add or remove query parameters after signing.

Fix the endpoint and region

The signature is scoped to a region. AWS’s checklist says to “confirm you’re using the correct region for the bucket” (AWS, Uploading objects with presigned URLs). The IAM guide adds that when the credential scope names a different region from the request, signature verification fails (AWS, Troubleshoot Signature Version 4).

You can check this without a console. Read the region in X-Amz-Credential, then compare it with the bucket’s region. On AWS, paginated ListBuckets requests return each bucket’s name and its region (AWS, Listing general purpose buckets). In this example command, <BUCKET> is your bucket name and the numbers are example page sizes:

Bash
aws s3api list-buckets --prefix <BUCKET> --max-items 10 --page-size 10

On R2, the region is a placeholder. Cloudflare’s SDK example sets region: "auto" with the comment “Required by SDK but not used by R2”, and uses the endpoint https://<ACCOUNT_ID>.r2.cloudflarestorage.com (Cloudflare R2, aws-sdk-js-v3 example).

On B2 and MinIO, use the endpoint and region that the provider’s own setup documentation gives for your bucket or server. Whatever the provider, the endpoint you sign for must be the host the browser calls, for the same reason as the proxy case above.

Fix clock skew and expired URLs

AWS says to keep the system clock in sync with an NTP server, because “even small time drifts can invalidate signatures” (AWS, presigned URLs). The signer writes its own time into X-Amz-Date, so check the clock on the machine that signs. AWS doesn’t say which clock matters for a presigned URL; that part is our inference.

AWS’s checklist also says to “check if the URL has expired and generate a new one if needed” (AWS, Uploading objects with presigned URLs). Compare X-Amz-Date plus X-Amz-Expires with the current UTC time. If a URL fails from curl, the browser and your server alike, and the keys check out, look at the clock and the expiry.

Fix a secret that doesn’t belong to the access key ID

Test the key pair with a known working tool

The secret must belong to the access key ID that signed the URL. AWS lists “The secret access key does not match the access key ID that you specified” as a cause, and says to verify the pair “with a known working implementation” (AWS, Troubleshoot Signature Version 4). On AWS, the AWS CLI is one: run the list-buckets command above with the same keys. If it also fails with SignatureDoesNotMatch, the pair is wrong. Also check that the access key ID in X-Amz-Credential is the one you meant to use.

Console steps: create a new access key pair on AWS

You can’t view a secret again after you create it, so if it is lost or mangled, create a new pair. These steps follow AWS, Manage your own access keys:

  1. Sign in to the IAM console with your account ID or alias, your IAM user name and your password.
  2. In the navigation bar on the upper right, choose your user name, then choose Security credentials.
  3. In the Access keys section, choose Create access key. If you already have two access keys, this button is deactivated, and you must delete one first.
  4. On the Access key best practices & alternatives page, choose your use case. If you still need a long-term key, choose Other, then choose Next.
  5. Optionally set a description tag value, then choose Create access key.
  6. On the Retrieve access keys page, choose Show or Download .csv file. AWS calls this “your only opportunity to save your secret access key”. Then choose Done.

Put the new pair into the signer’s configuration and rerun the curl baseline. Then deactivate the old key: in the Access keys section, choose Actions, then Deactivate (same AWS page). Keep the secret on the server that signs. The browser never needs it to use a presigned URL.

Console steps: create a new R2 API token

These steps follow Cloudflare R2, API tokens:

  1. In the Cloudflare dashboard, go to the R2 object storage page, then Overview.
  2. Under Account Details, select Manage next to API Tokens.
  3. Choose Create Account API token or Create User API token.
  4. Under Permissions, choose a permission type. If you choose Object Read and Write or Object Read, you can limit the token to specific buckets. Then select Create Account API token or Create User API token.
  5. Copy the Access Key ID and the Secret Access Key. Cloudflare says you will not be able to see the secret again after this step.

On other providers, replace the key pair in that provider’s console or admin tool, as its documentation describes.

A reference signer and upload script (AWS SDK for JavaScript v3)

When your app fails, it helps to compare it with a small program built only from the documented settings. This one signs a PUT URL with the Content-Type and checksum fixes applied, prints what was signed, and uploads a file with Node’s fetch, sending the same Content-Type a browser would. Node sends no Origin header and no preflight, so the script tests the signature, not CORS. It is built from the presigner README (@aws-sdk/s3-request-presigner), the SDK’s checksum settings (AWS SDKs and Tools, Data integrity protections) and Cloudflare’s client example (Cloudflare R2, aws-sdk-js-v3 example).

Untested: this program has not run against a bucket or a demo server. Try it on a test bucket first. The values in angle brackets are placeholders, and the environment variable names are examples you can change.

JavaScript
// presign-and-put.mjs
// Sign a presigned PUT URL the way a browser upload needs it, print what was
// signed, then upload a file to it with the same Content-Type a browser sends.
//
// Setup (a Node.js version with the global fetch):
//   npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
// Run:
//   ACCESS_KEY_ID=<ACCESS_KEY_ID> SECRET_ACCESS_KEY=<SECRET_ACCESS_KEY> node presign-and-put.mjs

import { readFile } from "node:fs/promises";
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";

const BUCKET = "<BUCKET>";
const KEY = "<KEY>";                   // example: uploads/test.png (safe characters only)
const FILE = "<PATH_TO_FILE>";
const CONTENT_TYPE = "<CONTENT_TYPE>"; // example: image/png, the exact value the browser will send
const REGION = "<REGION>";             // the bucket's region; "auto" on R2
const ENDPOINT = "<ENDPOINT>";         // R2: https://<ACCOUNT_ID>.r2.cloudflarestorage.com
                                       // other S3-compatible services: their endpoint
                                       // Amazon S3: set to "" to use the default endpoint

const client = new S3Client({
  region: REGION,
  ...(ENDPOINT ? { endpoint: ENDPOINT } : {}),
  credentials: {
    accessKeyId: process.env.ACCESS_KEY_ID,
    secretAccessKey: process.env.SECRET_ACCESS_KEY,
  },
  // From SDK 3.729.0 a CRC32 checksum is added by default. Calculate checksums
  // only when an operation requires one, so none ends up in the URL.
  requestChecksumCalculation: "WHEN_REQUIRED",
});

async function main() {
  let url;
  try {
    url = await getSignedUrl(
      client,
      new PutObjectCommand({ Bucket: BUCKET, Key: KEY, ContentType: CONTENT_TYPE }),
      {
        expiresIn: 300,                              // seconds
        signableHeaders: new Set(["content-type"]),  // enforce the Content-Type
      },
    );
  } catch (err) {
    console.error(`Could not sign the URL: ${err.name}: ${err.message}`);
    process.exit(1);
  }

  // What was signed: compare these with the browser's request in DevTools.
  const params = new URL(url).searchParams;
  console.log("X-Amz-SignedHeaders:", params.get("X-Amz-SignedHeaders"));
  console.log("X-Amz-Credential:   ", params.get("X-Amz-Credential"));
  for (const [name, value] of params) {
    const n = name.toLowerCase();
    if (n.startsWith("x-amz-checksum") || n === "x-amz-sdk-checksum-algorithm") {
      console.log(`Checksum parameter:  ${name}=${value}`);
    }
  }

  let res;
  try {
    const body = await readFile(FILE);
    res = await fetch(url, {
      method: "PUT",
      headers: { "Content-Type": CONTENT_TYPE }, // must equal the signed value
      body,
    });
  } catch (err) {
    console.error(`Upload did not get a response: ${err.message}`);
    process.exit(1);
  }

  if (!res.ok) {
    console.error(`Upload failed: HTTP ${res.status}`);
    console.error(await res.text()); // the error body the service returned
    process.exit(1);
  }
  console.log(`Uploaded ${FILE} to ${BUCKET}/${KEY} (HTTP ${res.status}, ETag ${res.headers.get("etag")})`);
}

main();

If your self-hosted server expects path-style URLs, add the client setting that its documentation gives for the SDK. The printed X-Amz-Credential contains your access key ID, and the URL works for anyone until it expires, so keep both out of public issues.

How to use the result:

  • If this script uploads and your app does not, compare the printed X-Amz-SignedHeaders and query parameters with your app’s URL, then go back to step 1.
  • If this script fails too, look at the keys, the region, the endpoint and the clock.
  • On Amazon S3, weigh Fix B from the checksum section instead of WHEN_REQUIRED, since the SDK maintainers recommend keeping the default protections there (aws-sdk-js-v3 #6810).

FAQ

Why does my presigned URL work with curl but fail in the browser?

The browser sends headers that your curl command doesn’t, such as a Content-Type taken from the file (Fetch Standard). If the URL was signed with a different Content-Type, or the SDK added checksum parameters, the signatures differ. Compare X-Amz-SignedHeaders with the PUT in DevTools, then see the Content-Type and checksum fixes above.

Does SignatureDoesNotMatch mean my IAM policy is wrong?

No. It means the signature the service calculated from your request differs from the one you sent (AWS, Troubleshoot Signature Version 4). AWS’s presigned-URL FAQ answers permission problems under a separate 403 Forbidden question (AWS, presigned URLs).

Can CORS cause SignatureDoesNotMatch?

CORS problems show up on the OPTIONS preflight, which is a separate request from the PUT (MDN, Preflight request). Compare the PUT‘s headers with the signature, not the preflight’s. One open issue reports a local emulator that answers a browser Origin header with SignatureDoesNotMatch (aws/aws-emulator #51), so test the real endpoint before you change your signing code.

Why does it fail only for some file names?

Characters in the key were probably encoded one way by the signer and another way in the request. AWS’s signing rules leave / unencoded in the key and encode a space as %20, not + (AWS, Create a signed request). Generate keys from safe characters on the server, and see the key encoding section above.

Why did uploads start failing after I updated the AWS SDK for JavaScript?

From 3.729.0 the SDK calculates a CRC32 checksum for uploads by default (AWS SDK for JavaScript v3, S3 checksums). One forum report shows the checksum parameters ending up in a presigned PUT URL, fixed with requestChecksumCalculation: 'WHEN_REQUIRED' (Fly.io community forum). Sign a URL and look for x-amz-checksum-* parameters in it.

Can I use an R2 presigned URL on my custom domain?

No. Cloudflare says R2 presigned URLs work with the S3 API domain, <ACCOUNT_ID>.r2.cloudflarestorage.com, and cannot be used with custom domains (Cloudflare R2, Presigned URLs). Sign for that domain and let the browser call it directly.

Check it in this order

  1. Read X-Amz-SignedHeaders and X-Amz-Credential in the presigned URL.
  2. Compare them with the Request Headers of the PUT, not the OPTIONS, in DevTools.
  3. Replay with curl and see whether the baseline passes.
  4. If the baseline passes, fix the browser side: Content-Type first, then checksum parameters.
  5. If it fails, fix the signer side: the URL and host, then the region and endpoint, then the clock, then the keys. Test against the real endpoint, not an emulator.

Try Opndrive

Opndrive gives any S3-compatible bucket a Drive-like web interface you host yourself.
See it on GitHub or read the docs.

Opndrive

Ready to take control of your S3 storage?

Connect your S3 bucket in minutes and start managing your files with Opndrive's beautiful, modern interface.

Build Opndrive with us

Live demos, reviews on your PRs, and a hand when you get stuck.

Be an early member
Join our Discord