Next.js Project Error - Sanity Login - Cannot Use Localhost:3333/desk

13 replies
Last updated: Sep 28, 2022
hello there. I am watching a tutorial about Sanity. There I have created a Next.js project. and run "sanity init" command. I have chosen e-commerce template with it. And at last, I run "sanity start" command. When I check localhost:3333 and login with my account at sanity.io , it says that I am not a member of this project. How so? Can anyone help me? I used "sanity login" command and it was successful, but can not use localhost:3333/desk.
Thank you in advance!
AI Update

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.ts or sanity.json file)
  • 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 logout in your terminal
  • Run sanity login again and make sure you're using the same email/account that you used when running sanity 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 --reconfigure

This 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 debug

This 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!

Hey
user U
! You're likely using a different provider to log in than you used to create your account. For example, if you created your account using Google, you'll need to log into your account using Google.
Thank you
user M
for your reply. But when I check, it is the same with my CLI login account.
If you go to the Projects section, then click on members, does your name have the same icon?
I have no projects there, cause I am using CLI to create a project. Should this local project somehow appear at sanity.io page?
Yes, a local project would still show up so I think it's possible that you've logged in to
<http://sanity.io/manage|sanity.io/manage>
using a different provider than you used in the CLI.
I don't want to take your too much time, but I think here is the problem. When I check my account details at Chrome developer tools, I see a different id apart from the one at localhost:3333 Chrome developer tools.
maybe it is relevant
Yes, I think it's relevant too! It confirms this last bit. You've accidentally made two accounts. I was able to find your project from the GET request in the image you shared and the account associated with that project uses Github to log in.
oh dear... just 15 seconds ago I have tried to log in with Github too and it solved my problem!
before seeing your reply, I tried to login with Github and that's it! Sorry for taking your time
user M
I have no clue when did I login with Github =/ Thank you very much!
No worries! Happy to help you get it sorted out. I've done this same thing myself before!
Haha =)) I am not alone then! Thank you again, have a good night! 🥳
You too!

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?