How to run 2 Sanity Studios locally without port conflict?

3 replies
Last updated: May 12, 2020
How do I run 2 studio's on local? I'm getting error
address already in use 127.0.0.1:3333
AI Update

You're getting that error because both studios are trying to use port 3333, which is Sanity Studio's default port. You have a couple of options to run multiple studios locally:

Option 1: Use the CLI flag (quickest)

When starting your second studio, specify a different port:

sanity start --port=3334

Or for the first studio use 3333 and the second use 3334, etc.

Option 2: Configure it in sanity.cli.ts (persistent)

If you want to permanently set a different port for one of your studios, add this to the sanity.cli.ts file:

import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
  server: {
    port: 3334, // or any other available port
  },
  // ...other settings
})

This way, each studio will automatically use its configured port when you run npm run dev or sanity start.

Bonus tip: If you need to kill whatever's using port 3333 on macOS, you can run:

lsof -ti :3333 | xargs kill -9

I typically use Option 2 for my projects since it means I don't have to remember which port each studio should use. Just set it once in the config and you're good to go!

More details in the running multiple studios locally answer and the localhost:3333 documentation.

Show original thread
3 replies
Hi Eystein, you can run one of your studios on a different port like this:
sanity start --port=1234
Hi Eystein, you can run one of your studios on a different port like this:
sanity start --port=1234
ah, that makes sense! thank you 🙂

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?