Next.js Project Error - Sanity Login - Cannot Use Localhost:3333/desk
This is a common issue that happens when you use sanity init to create a new project! Here's what's happening and how to fix it:
The Problem
When you run sanity init, the CLI creates a new project in your Sanity account and automatically adds you as a member. However, the sanity login command authenticates you with Sanity's servers, but it doesn't automatically sync which user created the project in all cases, especially if you have multiple accounts or if there was a hiccup during initialization.
Solutions to Try
1. Check Your Project Membership (Most Common Fix)
Go to sanity.io/manage and:
- Find the project that was created (it should match the project ID in your
sanity.config.tsorsanity.jsonfile) - Click on the project
- Go to the "Members" or "Team" section
- Make sure your account email is listed as a member with appropriate permissions (Administrator role is best for development)
- If you're not listed, you'll need to add yourself (though this might mean the project was created under a different account)
2. Verify You're Logged Into the Correct Account
Sometimes people have multiple Sanity accounts (personal, work, etc.):
- Run
sanity logoutin your terminal - Run
sanity loginagain and make sure you're using the same email/account that you used when runningsanity init - Check that the browser you're using for localhost:3333 is logged into the same Sanity account
3. Check Your Project ID
In your project folder, look at sanity.config.ts (or sanity.json for older projects) and verify the projectId matches the project you see in sanity.io/manage. If they don't match, you might be pointing to the wrong project.
4. Re-initialize If Needed
If nothing else works, you can start fresh:
# In your project directory
sanity init --reconfigureThis will let you either create a new project or select an existing one that you have access to.
5. Check for Organization Issues
Based on the Sanity platform documentation, members must be explicitly invited to each project. If the project was somehow created under an organization you don't have access to, you'll need an admin of that organization to invite you.
Quick Diagnostic
Run this command in your project directory to see which project and dataset you're connected to:
sanity debugThis will show you the project ID and help confirm you're working with the right project.
The most common fix is usually #1 or #2 - just making sure you're logged into the right account in both the CLI and your browser. Good luck!
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.