Sanity Cloud deployment failing with 502 bad gateway error
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 loginThen 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 deployThis 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 deploy6. 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 thread5 replies
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.