Skip to main content Skip to navigation
How to use ngrok to access your raspberry pi from anywhere.

How to use ngrok to access your raspberry pi from anywhere.

··Updated ·8 min readFresh·Updated Sep 28, 2026

TL;DR: After setting up Pi-hole and Selenium automations on a Raspberry Pi, the next challenge was accessing them remotely -- but the router didn't support port forwarding. Ngrok solves this by creating secure tunnels from the internet to your local device. This post shows how to set up ngrok on a Raspberry Pi to expose both the Pi-hole web admin panel (HTTP tunnel) and SSH access (TCP tunnel), so you can manage your Pi from anywhere on any network.

I have posted some blog posts regarding setting up pihole on raspberry-pi, and running selenium based tasks on raspberry-pi.

Check these here in blog posts section.

Why did I need remote access to my Raspberry Pi?

After putting these tasks as CLI commands on raspberry-pi, I wanted more accessibility for these. Like running these even if I am not in local network (at home).

There are two things that I wanted to access.

  1. Pihole web interface that runs on pihole's address at http://192.168.0.X/admin/
  2. SSH into pihole device to run the CLI commands that I made for some automations.

Why not use port forwarding?

In many routers these are sections where you can configure remote management or do port-forwarding. But my browser did not have these settings available.

It had a section to configure port-triggering, which is similar to port-forwarding but just inside the WAN network. That meant I can not access these things from mobile network or outside WAN.

Solution

Because of all these restrictions of my router I decided to use ngrok.

Ngrok is a useful utility to create secure tunnels to locally hosted applications using a reverse proxy. It is a utility to expose any locally hosted application over the web.

How do I set up ngrok on a Raspberry Pi?

  1. log on to your device
$ ssh [email protected]

It will prompt for password, Enter password and log into the device.

  1. Download ngrok and unzip it.
$ wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.tgz

$ tar -xvzf ngrok-stable-linux-arm.tgz
  1. Create a ngrok account. Where you will get an authtoken.
$ ./ngrok authtoken YOUR_NGROK_TOKEN

This token removes the 8-hour limit of ngrok tunnel. In free version, you get 1 tunnel with unique URL to access local app.

Version note: these steps use ngrok v2. In ngrok v3, the command is ngrok config add-authtoken YOUR_NGROK_TOKEN, and you download the ARM build from ngrok.com/download. Free-plan limits have changed since this post was written, so check ngrok's pricing page before you rely on them.

Now you are all setup for using ngrok…!!

GIF

How do I access the Pi-hole web interface with ngrok?

Use below command to create a tunnel for port 80. On port 80 there is pihole web interface. We will be able to access this from a unique ngrok URL.

$ /home/pi/ngrok/ngrok http 80 --log=stdout > /home/pi/ngrok.log &

Breakdown of command
/home/pi/ngrok/ngrok --> this is absolute location ngrok executable
http --> protocol to make tunnel for
80 --> port number of web app
--log=stdout > /home/pi/ngrok.log --> Log output file
& --> runs ngrok in background mode

Below is snapshot of how you can access web portal via ngrok tunnel.

ngrok terminal session forwarding HTTP traffic to a Raspberry Pi

How do I SSH into a Raspberry Pi with ngrok?

Use below command to create a tunnel for port 22. Using port 22 we can ssh into the device. Using unique URL provided by ngrok, we can ssh into raspberry-pi from anywhere.

$ /home/pi/ngrok/ngrok tcp 22 --log=stdout > /home/pi/ngrok.log &

Breakdown of command
/home/pi/ngrok/ngrok --> this is absolute location ngrok executable
tcp --> protocol to make tunnel for
22 --> port number of ssh
--log=stdout > /home/pi/ngrok.log --> Log output file
& --> runs ngrok in background mode.

Any ssh app like putty(Windows) or juiceSSH(mobile) can be used to connect to raspberry-pi

Below is snapshot of how ssh access from juiceSSH.

JuiceSSH app connected to a Raspberry Pi over an ngrok tunnel

Frequently Asked Questions

Is it safe to expose SSH through ngrok?

Only if you lock it down. Use SSH keys, set PasswordAuthentication no in /etc/ssh/sshd_config, and change the default pi password.

How do I start ngrok automatically on boot?

Create a systemd service that runs your ngrok command, then enable it with sudo systemctl enable ngrok. It will restart on reboot and after crashes.

Are there alternatives to ngrok?

Yes. Tailscale and Cloudflare Tunnel also give remote access without port forwarding. Tailscale builds a private network, so nothing is exposed to the public internet.

References