
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe "Session does not match project host" error with gatsby-source-sanity is typically caused by using an authentication token that belongs to a different Sanity project than the one configured in your Gatsby setup.
Running sanity logout and sanity login won't fix this issue because those commands manage your CLI session tokens, not the API tokens used by gatsby-source-sanity. The problem is specifically about a mismatch between:
The solution is to generate a new API token for the correct project:
projectId in gatsby-config.js)Your gatsby-config.js should look something like:
{
resolve: 'gatsby-source-sanity',
options: {
projectId: 'abc123', // Make sure this matches your project
dataset: 'production',
token: 'your-new-token-here', // Use the newly generated token
}
}This is a common issue that happens when you're working with multiple Sanity projects and accidentally mix up tokens between them. The error message is thrown from the gatsby-source-sanity plugin when it tries to fetch your GraphQL schema and detects that the authentication token doesn't belong to the project you're trying to access.
Make sure the projectId in your config matches the project for which you generated the token, and you should be good to go!
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store