cli: [Bug]: Could not start tunnel, max retries reached

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

App

Expected behavior

npm run dev should start a tunnel & start the dev server. Instead it gives an error. The previous issue https://github.com/Shopify/cli/issues/1980 was closed without resolution. The workaround to spin up a tunnel first & then use the tunnel-url with npm run dev works but I don’t think is the expectd workflow, if it is, it would be good for it to be documented in https://shopify.dev/docs/apps/getting-started/create.

Actual behavior

│  Could not start tunnel, max retries reached                                                                                         │
│                                                                                                                                      │
│  To investigate the issue, examine this stack trace:                                                                                 │
│    at pollTunnelStatus (@shopify/app/src/cli/services/dev/urls.ts:106)                                                               │
│      if (result.status === 'error') return reject(new BugError(result.message))                                                      │
│    at (@shopify/app/src/cli/services/dev/urls.ts:120)                                                                                │
│      pollTunnelStatus()                                                                                                              │
│    at new Promise                                                                                                                    │
│    at pollTunnelURL (@shopify/app/src/cli/services/dev/urls.ts:101)                                                                  │
│      return new Promise<string>((resolve, reject) => {                                                                               │
│    at generateFrontendURL (@shopify/app/src/cli/services/dev/urls.ts:89)                                                             │
│      const url = await pollTunnelURL(options.tunnelClient)                                                                           │
│    at dev (@shopify/app/src/cli/services/dev.ts:121)                                                                                 │
│      generateFrontendURL({                                                                                                           │
│    at run (@shopify/app/src/cli/commands/app/dev.ts:106)                                                                             │
│      await dev({                                                                                                                     │

Verbose output

npm verb cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@9.6.7
npm info using node@v18.16.0
npm verb title npm run dev
npm verb argv "run" "dev" "--loglevel" "verbose"
npm verb logfile logs-max:10 dir:/Users/nitin/.npm/_logs/2023-06-14T10_54_48_243Z-
npm verb logfile /Users/nitin/.npm/_logs/2023-06-14T10_54_48_243Z-debug-0.log

> checkout360@1.0.0 dev
> shopify app dev

╭─ info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                      │
│  Using your previous dev settings:                                                                                                   │
│                                                                                                                                      │
│    • Org:          <org name>                                                                                                         │
│    • App:          <appname>                                                                                                       │
│    • Dev store:    <storeurl>.myshopify.com                                                                            │
│    • Update URLs:  Not yet configured                                                                                                │
│                                                                                                                                      │
│  To reset your default dev config, run `npm run dev -- --reset`                                                                      │
│                                                                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─ error ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                      │
│  Could not start tunnel, max retries reached                                                                                         │
│                                                                                                                                      │
│  To investigate the issue, examine this stack trace:                                                                                 │
│    at pollTunnelStatus [as _onTimeout] (@shopify/app/src/cli/services/dev/urls.ts:106)                                               │
│      if (result.status === 'error') return reject(new BugError(result.message))                                                      │
│    at listOnTimeout (node:internal/timers:569)                                                                                       │
│    at processTimers (node:internal/timers:512)                                                                                       │
│                                                                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

npm verb exit 1
npm verb code 1

Reproduction steps

follows the steps in https://shopify.dev/docs/apps/getting-started/create

  1. npm init @shopify/app@latest
  2. npm install
  3. npm run dev

Operating System

Mac OS

Shopify CLI version (check your project’s package.json if you’re not sure)

3.46.5

Shell

iTerm2

Node version (run node -v if you’re not sure)

v18.16.0

What language and version are you using in your application?

Node

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 26 (8 by maintainers)

Most upvoted comments

For what it’s worth, there may be a small possibility that cloudflare tunnels are down or having issues at times. I’ve just spent my morning trying to debug this issue and then found out that I couldn’t create my own tunnel using cloudflared cli, which then lead me to realise cloudflare are having issues.

https://isdown.app/integrations/cloudflare/cloudflare-sites-and-services-cloudflare-tunnel

I came across this issue too. I could set up a workaround with ngrok.

  1. ngrok http 5000
  2. Copy the “forwarding” address
  3. Set up the server for testing as yarn dev --tunnel-url https://the-forwarding-addres.app:5000 (the name of the port after the address)

I came across this issue too. I could set up a workaround with ngrok.

1. `ngrok http 5000`

2. Copy the "forwarding" address

3. Set up the server for testing as `yarn dev --tunnel-url https://the-forwarding-addres.app:5000` (the name of the port after the address)

Worked for me also. Thanks!!

As instructed by @NanyThery , the following commands worked for me:

ngrok http 5000
// Copy the "forwarding" address
npm run dev -- --tunnel-url  <forwarding-address>:5000

My dev environment :

  1. WSL2 / Ubuntu 20.04
  2. Windows 10
  3. Shopify Remix App

I started facing this issue suddenly when the Cloudflare services started facing issues today.