Sanity Cloud deployment failing with 502 bad gateway error

5 replies
Last updated: Jul 20, 2023
Hello! Wondering if anyone else is running into this issue. I am using Sanity Cloud and suddenly yesterday I am unable to deploy changes. (Sanity start & the local version of the studio works perfectly still). Thanks in advance!Error is
502 bad gateway -> full error in the comment
AI Update

I feel your pain with 502 errors – they're frustrating! A 502 Bad Gateway error when running sanity deploy typically indicates a temporary server-side issue between Sanity's hosting infrastructure and your deployment request.

Here are the steps I'd recommend:

1. Check Sanity's Status Page First

Visit status.sanity.io to see if there's an ongoing incident or maintenance affecting Studio deployments. If there's a known issue, you'll see it reported there and can subscribe to updates.

2. Verify Your Authentication

Make sure you're properly authenticated. The sanity deploy command requires valid authentication. Try running:

sanity login

Then attempt your deploy again. Sometimes auth tokens can expire or get corrupted, especially in CI/CD environments where you need to set the SANITY_AUTH_TOKEN environment variable.

3. Try Deploying with Debug Info

Run your deploy with verbose logging to get more details:

SANITY_DEBUG=* sanity deploy

This will show you exactly where the deployment is failing and might reveal if it's a network issue, build problem, or server error.

4. Check Your Network/Firewall

502 errors can sometimes be caused by network issues on your end. Try:

  • Deploying from a different network connection
  • Temporarily disabling VPN if you're using one
  • Checking if your firewall is blocking connections to Sanity's servers

5. Clear Build Cache and Retry

Sometimes cached build artifacts can cause issues:

rm -rf node_modules/.sanity
sanity deploy

6. Contact Sanity Support

If none of the above works and there's no reported outage on the status page, reach out to Sanity support with:

  • Your full error message (including the one from your comment)
  • Project ID
  • Timestamp of when the issue started
  • Output from the SANITY_DEBUG=* command

Since you mentioned this started "suddenly yesterday" and your local Studio (sanity start) works fine, this really does sound like it could be a temporary infrastructure issue on Sanity's end. The fact that your local development works confirms your Studio code itself is fine – it's specifically the deployment pipeline having issues.

Keep an eye on that status page, and if it's not resolved within a few hours, definitely reach out to support with your debug logs!

Show original thread
5 replies
sanity deploy
✔ Checking project info
✔ Clearing output folder (20289ms)
✔ Building Sanity (15961ms)
✔ Building index document (34ms)
✔ Minifying JavaScript bundles (73289ms)
✔ Verifying local content
✖ Deploying to Sanity.Studio

Error: POST-request to <https://ribanipd.api.sanity.io/v1/deploy> resulted in HTTP 502 Bad Gateway
    at onResponse (/usr/local/lib/node_modules/@sanity/cli/lib/_chunks/loadEnv-23535f1a.js:1238:13)
    at applyMiddleware (/usr/local/lib/node_modules/@sanity/cli/node_modules/get-it/dist/index.cjs:59:13)
    at onResponse (/usr/local/lib/node_modules/@sanity/cli/node_modules/get-it/dist/index.cjs:105:22)
    at /usr/local/lib/node_modules/@sanity/cli/node_modules/get-it/dist/index.cjs:132:55
    at callback (/usr/local/lib/node_modules/@sanity/cli/node_modules/get-it/dist/index.cjs:487:46)
    at /usr/local/lib/node_modules/@sanity/cli/node_modules/get-it/dist/index.cjs:550:14
    at DestroyableTransform.<anonymous> (/usr/local/lib/node_modules/@sanity/cli/node_modules/get-it/dist/index.cjs:263:13)
    at Object.onceWrapper (node:events:625:28)
    at DestroyableTransform.emit (node:events:523:35)
    at endReadableNT (/usr/local/lib/node_modules/@sanity/cli/node_modules/readable-stream/lib/_stream_readable.js:1010:12)
Maybe try logging out &amp; logging back into the CLI? Do you know what role you have?
thanks
user M
! I tried to log out and log in but the same error still exists (in fact, I don't think I had to log in previously to deploy? this is an inherited github repo so not sure if something was already set up). the user account is administrator.
Just to close this out in case anyone else is having a similar problem. I was able to resolve by building the project separately first
sanity build
and then deploying the studio with minimum options
sanity deploy --no-minify --no-build
Thanks for sharing your solution!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?