The easiest way to access your Raspberry Pi from the web for testing things out (like a simple web server) is to use a service called ngrok. It creates a secure tunnel to your Pi’s locally running server, giving you a simple public URL that you can use to access it from anywhere online.

A Pi floating over the globe

Your Pi shall soon be able to communicate with the globe!

To install it on your Pi, go ngrok.com, scroll to the “Download and Installation” section and copy the URL of the download link next to “Linux ARM”:

ngrok's download options

The “Download” button you’ll want to right click for the URL

Then, open up your command line/terminal on your Pi and type in the following, where the URL is the URL you copied from above:

wget "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip"

You’ll then need to have a way to unzip that file. If you haven’t unzipped anything on your Pi in the past, you’ll need to install the zip package using the following command:

apt-get install unzip

Then unzip ngrok using the following:

unzip ngrok-stable-linux-arm.zip

That will unzip the file “ngrok” at this location. Run it using the following command (replace “80” with the port you’d like to be able to access):

./ngrok http 80

You should see output that looks like so:

ngrok's output when running

Find the “Forwarding http://0acc59c9.ngrok.io -> localhost:80” line, that’s your URL

The URL you’ll want will look like “http://0acc59c9.ngrok.io” (ngrok will generate you a unique one, so don’t try this one!). If you enter your URL into wherever you are trying to access your Raspberry Pi from, you should access that service on your Pi, just as if you were accessing it from your local network! Well, not quite as quickly but still quite speedily!

(Note: you do not need to include the port number in that request as ngrok automatically is directing the request to the port you set)

Know other emerging tech enthusiasts who might want to read this too? Please like and share this post with them!

Would you like to republish this article in your own publication?
Contact Dev Diner to request official republication of this article.

Leave a Reply

Your email address will not be published. Required fields are marked *

Want more?