Facing ngrok error 6022 even after installing the auth token?

ngrok error - ERR_NGROK_6022

If you’re also facing the ngrok error ERR_NGROK_6022 then ngrok asks you to sign up for a free ngrok account and install the authtoken. But in a particular scenario, even after installing the authtoken, you get the same weird error. In this post, we will look into that particular scenario and we will see, how you may install the authtoken properly.

If you’re unaware of ngrok yet, then

ngrok is simply the fastest way to put your localhost app on the internet.

Suppose, I have a sample web application running on port say 3002 then I can make my web application accessible through internet using the command below:

ngrok http 3002

Then it will display you the forwarding links as shown in figure below:

ngrok status with forwarding links

You may simply copy the forwarding link and open the link in your browser to view your localhost web application. But if you have not registered for a ngrok account and installed the ngrok authtoken then it will give you the following error while browsing the forwarding link:

To resolve this issue, you may simply register for an account on ngrok website and you will find the instructions to install the ngrok token as shown in figure below:

Now, just run the below command to install the ngrok token:

ngrok config add-authtoken <AUTHTOKEN>

After installing the authtoken, you will need to rerun the ngrok agent:

ngrok http 3002

And again copy the forwarding link from the command output and open the link in the browser. This time, you will see a warning message from ngrok:

Simply click on button Visit Site to view your localhost web application on internet. Note that, this warning will come only for the first time on a machine for a particular generated link. You may share this link with your colleagues or friends to get feedback on your localhost application quickly.


Now, let’s talk about a special scenario in which even after installing the authtoken, you get the same ngrok error with code 6022. This error occurs because probably you have installed multiple versions of ngrok binary through multiple ways.

One way is to download the ngrok binary directly and run it. Another way is through Node package manager npm.

In my scenario, I was developing a Jira Cloud plugin using Atlassian Connect for NodeJS Express. On my system, global ngrok binary was already installed and authtoken was also already installed. This Atlassian connect framework internally uses the ngrok npm module to expose the developed Jira plugin to internet. But after following the generated tunnel link by the framework, I keep getting the annoying ngrok error ERR_NGROK_6022.

To fix this error, you will need to figure out the correct ngrok binary used by the framework (in my case, the framework was Atlassian Connect for NodeJS Express). If it is installed locally as a dependency then binary will be available at the following location in your project directory:

The command for installing the authtoken through npm module was also different. You may use the following command to install the authtoken:

The above command will output the location of file where the authtoken is saved. Notice that this time, authtoken is saved in a different file. The file location will look like this:

OS X

/Users/username/.ngrok2/ngrok.yml

Linux

/home/username/.ngrok2/ngrok.yml

Windows

C:\Users\username\.ngrok2\ngrok.yml

Now, restart your application again which generates the ngrok URL and you should be able to view your web application using ngrok generated URL. Share your experience via comments if you have also faced this error and wasted hours of time.