Why does GraphQl show a 401 error after one hour of idle on my app?

Topic summary

Developers are encountering a 401 GraphQL error after their Shopify app idles for 10 minutes to 2 hours during local development. The issue appears across different setups, including Remix and PHP templates, and persists even on different machines and partner accounts.

Common triggers:

  • Running local dev server with npm run dev
  • One user specifically linked it to checkout extensions, though others report it without extensions
  • Occurs after upgrading Shopify CLI in some cases

Proposed solutions:

  1. Delete .shopify folder from app root and restart via CLI (requires re-authentication)
  2. Verify .env configuration includes SHOPIFY_API_KEY, SHOPIFY_API_SECRET, SCOPES, and API_VERSION
  3. Re-authenticate CLI using shopify logout then shopify login
  4. Check Node version compatibility (v18 or v22)
  5. Ensure Authorization header contains valid token and endpoint matches API type

Current status: A GitHub issue was opened but remains unresolved. The root cause—likely related to token expiration or session management—has not been officially addressed.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hi! Is someone experiencing an issue like this? Whenever I start my shopify app, within about one hour I get:

"Error: GraphQL Error (Code: 401): {"response":{"error":"","status":401,"headers":{}},"request":{"query":"\n query FindApp($apiKey: String!) {\n app(apiKey: $apiKey) {\n developmentStorePreviewEnabled\n }\n }\n","variables": ...".

I narrowed it down to being checkout extension. Tried to use different computer and partner account and still got the same issue.

Steps:

  1. npm init @Shopify_77 /app@latest //chose remix
  2. cd your-app
  3. npm run shopify app generate extension
  4. npm run dev
  5. Went into the app and checked that I have the checkout extension
  6. Wait about 1-2 hours and the previously mentioned error appears.

Happy to give more details if you think of anything. Here are my versions:

“@shopify/cli”: “3.48.6”,

“@shopify/app”: “3.48.6”,
node -v: v18.17.1

1 Like

+1 same issue for me. i’ve had it in as little as 10 minutes or so. mine isn’t a checkout extension; it seems just related to running the local dev server

stack trace isn’t very helpful:

at makeRequest (file:///.../node_modules/graphql-request/build/esm/index.js:284:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async debugLogResponseInfo (file:///.../node_modules/@shopify/cli-kit/dist/private/node/api.js:13:20)
at async graphqlRequest (file:///.../node_modules/@shopify/cli-kit/dist/public/node/api/graphql.js:20:22)
1 Like

I have the same error after idling for a short while.

Was working ok before I upgrade shopify cli.

Error: GraphQL Error (Code: 401): {“response”:{“error”:“”,“status”:401,“headers”:{}},“request”:{“query”:“\n query FindApp($apiKey: String!) {\n app(apiKey: $apiKey) {\n developmentStorePreviewEnabled\n }\n }\n”,“variables”:{“apiKey”:“XX”}}}

not sure if modify the esm/index.js to catch error rather than ‘throw’ will help..

I created an issue on github a few days ago, but still haven’t gotten the response back. Hopefully it’s the right repository. As for the issue - I’m still getting it.
https://github.com/Shopify/shopify-app-template-remix/issues/330

1 Like

I had the same problem with the Shopify PHP Template.

In .env file I didn’t give

SHOPIFY_API_KEY=xxxx
SHOPIFY_API_SECRET=xxx
SCOPES=“read_themes,write_products,read_orders,write_orders”
API_VERSION=2025-01

so, created the error.

1 Like

This can happen due to a hung app state. To fix it, delete the .shopify folder from the root of your app, then rerun the app using the Shopify CLI. You’ll be prompted to log in to Shopify for verification, and everything should work fine afterward.

2 Likes

I have the same error, simple solution i try to solve it , check the node version in your environment, v22 or v18 …

  • Make sure your request includes the Authorization header with a valid token.

  • Confirm the endpoint matches the type of query (Partners API vs Admin API).

  • If using Shopify CLI, try re-authenticating:

Steps:

  1. shopify logout
  2. shopify login