valet: Running `valet share` throws an error `ERR_NGROK_4018`

The problem

Ngrok recently changed their policy to require anyone to sign up before they can share with it, so using valet share will trigger first this error:

You must signup for ngrok and add your authtoken to perform this operation.

Sign up for an account: https://dashboard.ngrok.com/signup
Install your authoken: https://dashboard.ngrok.com/get-started/your-authtoken

ERR_NGROK_4018

And then this error:

In CurlFactory.php line 210:

  cURL error 7: Failed to connect to 127.0.0.1 port 4040 after 1 ms: Connecti
  on refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for htt
  p://127.0.0.1:4040/api/tunnels

Thanks to @driesvints for finding the error right away and @mpociot for validating it.

Possible solutions

The simplest short-term solution for users is to sign up for Ngrok and authenticate.

Longer-term, we’ll want to write that up in the docs, and also update Valet to give a better error in this circumstance.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 31 (10 by maintainers)

Most upvoted comments

on an M1 Mac the issue appears to be the ngrok-arm binary doing the following worked for me with no other changes to scripts/params required

cd ~/.composer/vendor/laravel/valet/bin/
mv ngrok-arm ngrok-arm.old
ln -s ngrok ngrok-arm

valet share works as expected after this

Another way to share valet sites using Ngrok that seems to work for me.

# Non SSL Site
ngrok http 127.0.0.1:80 -host-header="site.test"

# SSL Site
ngrok http 127.0.0.1:443 -host-header="ssl-site.test"

Though if we update this on valet core, this kinda breaks the fetch-share-url.sh script. Trying to figure out if we can make it work without breaking existing flows.

I can also reproduce it now btw. Taking another look later today.

For now, as a workaround what I do is run php artisan serve and then run

ngrok http {artisan server port} --hostname={ngrok custom hostname} --region={nearest region}

and this works perfectly.

Leading onto this, I’m getting this issue within my Laravel 9 app.

Failed to complete tunnel connection

The connection to https://<x>.ngrok.io/ was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address analyse.net.test:80.

Make sure that a web service is running on analyse.net.test:80 and that it is a valid address.

The error encountered was: dial tcp: lookup analyse.net.test on 194.168.4.100:53: no such host

Any reason why? I can connect to analyse.net.test locally.

@KevinSleegers Use Expose from BeyondCode in the meantime. Works also pretty well.

Hi - I was experiencing the same issues as @heychazza yesterday. I would share my local site and see the “Failed to complete tunnel connection” message.

I tried a few different things, but in the end I discovered this was due to the ‘ngrok-arm’ binary being used. If I modify the valet file on line 84 to use the regular ‘ngrok’ binary and re-share I experience no issue.

I can’t claim to know enough about why this would be the case. I am using an m1 mac, so my cli will return arm64.

If I can do anything to help investigate this issue further, then please let me know!

on an M1 Mac the issue appears to be the ngrok-arm binary doing the following worked for me with no other changes to scripts/params required

cd ~/.composer/vendor/laravel/valet/bin/
mv ngrok-arm ngrok-arm.old
ln -s ngrok ngrok-arm

valet share works as expected after this

Based on this, what i did is just download the proper version from the ngrok site and replace it.

download from https://dashboard.ngrok.com/get-started/setup replace the downloaded version in ~/.composer/vendor/laravel/valet/bin/

and like it says, valet share works just fine after that.

(M1 mac here, download the arm64 version)

Think I’m just gonna revert that separate binary PR. The OP might have been on an older ngrok version.

on an M1 Mac the issue appears to be the ngrok-arm binary doing the following worked for me with no other changes to scripts/params required

cd ~/.composer/vendor/laravel/valet/bin/
mv ngrok-arm ngrok-arm.old
ln -s ngrok ngrok-arm

valet share works as expected after this

This is what I did and it worked for me

Completely uninstalled Valet, including deleting all brew files, the valet folder, etc, then installed again, running:

  • valet link
  • valet share

I’m still getting this error, so I’m assuming Ngrok had an update or something.

CleanShot 2022-02-09 at 6 36 40@2x CleanShot 2022-02-09 at 6 36 45@2x