Cloudflared forge tunnel not working

I have upgraded to latest forge cli version 10.2.0 and when I am trying to run the command forge tunnel it is giving me the following error in the terminal:

Error: spawn /usr/local/lib/node_modules/@forge/cli/node_modules/cloudflared/bin/cloudflared ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /usr/local/lib/node_modules/@forge/cli/node_modules/cloudflared/bin/cloudflared',
  path: '/usr/local/lib/node_modules/@forge/cli/node_modules/cloudflared/bin/cloudflared',
  spawnargs: [
    'tunnel',
    'run',
    '--token',
    '<token-here>',
    '--url',
    'localhost:50709',
    '--protocol',
    'http2',
    '3d6c5e8c-34a7-45e0-8ddb-9488617441de'
  ]
}

Kindly help in resolving this issue.

Hi @TejasviGarg, the error that you are getting back (ENOENT) suggests that the Cloudflare binary included in the Forge CLI package is missing. I would suggest reinstalling the Forge CLI as a potential solution.

1 Like

I resolved this issue through:

  1. delete cli folder /usr/local/lib/node_modules/@forge/cli in my Macbook
  2. unset development
  3. npm install -g @forge/cli
  4. forge tunnel

Hi @BoZhang
I can’t resolve this issue even if I reinstall forge CLI today. Could you please help take a look? Thanks.

Error: spawn /usr/local/lib/node_modules/@forge/cli/node_modules/cloudflared/bin/cloudflared ENOENT

/usr/local/lib/node_modules/@forge/cli/node_modules/@forge/tunnel/out/services/create-tunnel-service.js:33
            throw new cli_shared_1.BaseError(undefined, cli_shared_1.Text.tunnel.error.cloudflaredError);
            ^

BaseError: Failed to start cloudflared. Rerunning the command with --verbose may give more details.
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@forge/cli/node_modules/@forge/tunnel/out/services/create-tunnel-service.js:33:19)
    at ChildProcess.emit (node:events:514:28)
    at ChildProcess.emit (node:domain:489:12)
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  requestId: undefined
}

Node.js v18.17.1

Hi @YY1, from the error message, it seems like the Cloudflare binary isn’t available for you local installation of the CLI. I can’t seem to reproduce this with the latest version. Can you let me know which version of the CLI you are using?

I reinstalled the latest Forge CLI several times.
image

Is there any update of Forge CIL related to Cloudflare recently? I didn’t have this issue a few days ago.

There shouldn’t have been any changes related to the tunnelling over the last couple of weeks.
I wasn’t able to reproduce it myself on version 10.13.1.
The error message that you are getting:

Error: spawn /usr/local/lib/node_modules/@forge/cli/node_modules/cloudflared/bin/cloudflared ENOENT

Seems to suggest that the Cloudflare binary doesn’t exist for the installation of Forge CLI that you are using. Can you double check that the Forge CLI you are re-installing is the one located here?

I should install cloudflare in this folder, right? I’ve never done it before, but I will have a try.

you shouldn’t have to install it manually, I am just wondering if the Forge CLI that you are re-installing is the one that is referencing the missing Cloudflare binary.

I just deleted the cli folder and used this command to install: npm install -g @forge/cli@latest again. The result still failed.

can you run which forge

yeah. the result is:
/usr/local/bin/forge

Forge CLI is installed at: /usr/local/lib/node_modules/@forge/cli

Did you use the not official registry to install the forge?
I can reproduce it with tencent registry or huaweicloud reigstry also

Oh, I’ve never noticed the registry in Macbook. Everything got fine before with the same operations. But recrently, it doesn’t work for me. Quite confused!!

@BoZhang


都是这样的, 无论什么npm版本 forge版本 nodejs版本 这个东西能手动安装么 跟docker是否有关系,我在windows上和自己的服务器上都可以复现

1 Like

我昨天在 forge->cli目录手工安装了 cloudflare,但是还是没成功

Hi @IssacSun , thanks for the insight.

Let’s continue the conversation in English so that the wider community can follow along.

I wouldn’t try installing the CLI manually, it’s probably possible, but relying on NPM to install it is the way to go.

Can you let me know what NPM registry you are using, the version of NPM you are using and also if you noticed the issue with previous versions of Forge CLI.

I got this issue before and resolved with this method. But it doesn’t work now.

I’ve raised a support ticket: ECOHELP-54132

Hi @YY1 @IssacSun , what npm registry and npm version are using? can you also try to install cloudflared manually (npm i -g cloudflared) and seeing if that works?
cloudflared is a transitive dependency for the Forge CLI and we need it for tunneling, it seems like it’s not being installed.

1 Like


npm registry : https://r.cnpmjs.org/