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

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

RolandsK
Shopify Partner
4 0 2

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/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
Replies 6 (6)

appdev2023
Shopify Partner
21 2 3

+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)

leonpl
Shopify Partner
13 0 3

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..

 

RolandsK
Shopify Partner
4 0 2

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

nafeeur10
Shopify Partner
23 0 3

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. 
Please let me know if it works by giving it a like or marking it as a solution!
Working as Technical Lead at Akij iBOS
If you need any help, mail me at inafeeur [at] gmail.com or Give me a text message on Skype nafeeur.rahman1

abdullahc
Shopify Partner
6 1 1

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.

Samita-Danny
Shopify Partner
12 0 1

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

 

Sami B2B Wholesale — Unlock powerful wholesale features
Sami Request a Quote — Let customers request quotes easily

If our reply helped, please give it a Like or mark it as a Solution!