Hi everyone. I'm new to using Sanity and having a bit of an issue with local development, and wondering if someone is able to point me in the right direction. The issueis...

8 replies
Last updated: Dec 29, 2020
Hi everyone. I'm new to using Sanity and having a bit of an issue with local development, and wondering if someone is able to point me in the right direction.
The issue is that when I run
sanity start
and then open my browser to
<https://localhost:3333>
, it seems to be using a previous Sanity project, and not the project I am running the
sanity start
command from
I have tried disabling the other project, logging in and out of Sanity via the CLI, clearing browser cache, re-installing
@sanity/cli
globally, but still having this issue
Is there something I am missing? How can I clear the unwanted project from my local development?

Thanks in advance for any replies.
AI Update

Based on the documentation and a similar case in the Sanity community, this appears to be a port conflict issue rather than a browser cache or service worker problem with Sanity Studio.

First, verify your project configuration:

Check your sanity.config.ts (or sanity.config.js) file to confirm it has the correct projectId and dataset specified in the configuration:

import { defineConfig } from 'sanity'

export default defineConfig({
  projectId: 'your-project-id',
  dataset: 'production',
  // ... other config
})

You can also check your sanity.cli.ts file to ensure the API configuration is correct:

import { defineCliConfig } from 'sanity/cli'

export default defineCliConfig({
  api: {
    projectId: 'your-project-id',
    dataset: 'production'
  }
})

Kill any processes using port 3333:

The most likely cause is that another process is running on port 3333 and serving content from your old project. You'll need to terminate it:

  • macOS/Linux: Run lsof -ti :3333 | xargs kill -9 in your terminal
  • Windows: Use netstat -ano | findstr :3333 to find the process ID, then taskkill /PID <process-id> /F

Try a different port:

As a quick workaround, you can run your Studio on a different port using:

sanity start --port=3334

Or configure it permanently in your sanity.cli.ts:

import { defineCliConfig } from 'sanity/cli'

export default defineCliConfig({
  api: {
    projectId: 'your-project-id',
    dataset: 'production'
  },
  server: {
    port: 3334
  }
})

Restart your machine:

In a similar reported case, the issue was resolved by restarting the machine, which cleared a stray process running the old project on the same port.

The issue you're experiencing is most likely a port conflict where another process is serving content on localhost:3333, rather than a browser or Sanity Studio caching issue. The steps above should help you identify and resolve the conflict.

Check
sanity.json
make sure it has the correct project
Thanks. It does have the correct project
Strange usually logging back in with
sanity login
does the trick, maybe check that your
sanity
npm command is up to date to the latest?
Ah, like checking that the CLI is up to date? I recently re-installed the CLI so I think it's good as far as that goes
To clarify, I am still able to use my new project, but I need to skip local development. I can deploy the GraphQL API to the 'live' Studio, and I can log into it and see the correct schema that way, but it seems
sanity start
is caching a previous project and blocking local development on the Studio
Just now I also tried deleting all of my other Sanity projects, but still the same issue. Here is a screen shot of the error I get when navigating to
localhost:3333
Hi
user J
can you DM me the project id in question? Looks like it has been disabled? Are you able to enable in on manage.sanity.io ?
Resolved on DM. Restarting the machine did the trick. Seemed to be a stray process with an old project running on the same port.

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?