DEV Community

Roel
Roel

Posted on

How to: install ngrok on your Raspberry Pi

Ngrok is a fantastic tool that creates secure tunnels from public URLs to your localhost. It allows you to test webhook integrations, share your progress, and collaborate on projects without deploying your code to a remote server. With just a single command, ngrok generates a unique public URL that forwards requests to your local development environment.

However, there's a small catch when using the free version of ngrok: it assigns random URLs each time you create a tunnel. This can be inconvenient for certain use cases.

https://ngrok.com/


Free plan steps

Here's a step-by-step guide on how to install and run ngrok on your Raspberry Pi:

  1. Download ngrok for Linux ARM:
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip
Enter fullscreen mode Exit fullscreen mode
  1. Unzip the downloaded file:
unzip ngrok-stable-linux-arm.zip
Enter fullscreen mode Exit fullscreen mode

This will extract the ngrok executable in the current directory.

  • (Optional) Move the ngrok executable to a directory in your system's PATH. This way, you can run ngrok from anywhere in your terminal without specifying its full path. For example, you can move it to /usr/local/bin:
sudo mv ngrok /usr/local/bin
Enter fullscreen mode Exit fullscreen mode
  1. To run ngrok, simply type ngrok followed by the command and arguments. In your case, you want to expose your Flask server running on port 5000:
ngrok http 5000
Enter fullscreen mode Exit fullscreen mode

Now, ngrok should create a secure tunnel, and you should see the HTTPS URL provided by ngrok.


However, the anonymous plan only allows you to create a tunnel for 2 hours. To prevent this we can create a free account.

Extend the options with an account

To get started with custom subdomains, you'll first need to sign up for a paid ngrok plan. The Basic plan is a great starting point and can be found on the ngrok pricing page: https://ngrok.com/pricing

Once you have signed up for a basic or plan, you'll need to authenticate your local ngrok client. Head over to your ngrok dashboard and find your unique authtoken. Then, run the following command in your terminal to authenticate:

./ngrok authtoken <your_ngrok_authtoken>
Enter fullscreen mode Exit fullscreen mode

Creating a custom subdomain using the paid plan

With authentication out of the way, we can now create a custom subdomain for our tunnel. Use the --subdomain flag while starting the ngrok tunnel:

./ngrok http -subdomain=mycustomsubdomain 5000
Enter fullscreen mode Exit fullscreen mode

This command will create an HTTP tunnel with the subdomain mycustomsubdomain.ngrok.io, forwarding to port 5000 on your local machine. Voilà! Now you have a consistent URL that you can use and share for your projects.

Top comments (2)

Collapse
 
ghoshbishakh profile image
Bishakh Ghosh • Edited

You don't need to install Ngrok. You can simply run the pinggy.io command to get a tunnel:
ssh -p 443 -R0:localhost:8000 -L4300:localhost:4300 qr@a.pinggy.io

Image description

Collapse
 
iamrule profile image
Roel

Thanks for the tip! This looks like a very usefull tool! I will look into it.