Ngrok on Ubuntu under Windows Subsystem for Linux (WSL)
Jomer Ventolero
Posted on November 29, 2024
Ngrok Installation Guide for Ubuntu on WSL
This guide will help you install Ngrok on your Ubuntu environment running under Windows Subsystem for Linux (WSL). Ngrok is a tool that allows you to expose your local server to the internet.
Prerequisites
Ensure that you have WSL installed on your Windows machine with Ubuntu as your chosen distribution. You should also have an active internet connection to download Ngrok.
Step 1: Open Your WSL Terminal
Launch your WSL terminal (Ubuntu) from the Windows start menu.
Step 2: Update Your Package List
Before installing any packages, it's a good idea to update the package list. Run:
sudo apt update
Step 3: Remove Any Previous Ngrok Files
To avoid confusion, remove any previous downloads of Ngrok:
rm ngrok.zip ngrok-stable-linux-amd64.zip
Step 4: Download Ngrok
You can download the latest version of Ngrok directly. Visit the Ngrok download page to get the most current URL, or use the command below to download it:
wget https://bin.equinox.io/c/111111/ngrok-stable-linux-amd64.zip -O ngrok.zip
Note: Replace 111111
with the actual key you find on the Ngrok download page if necessary.
Alternate Download Method
If the above command fails, you can use the following command, which extracts the download link directly from the Ngrok website:
curl -s https://ngrok.com/download | grep -o 'https://[^"]*ngrok-stable-linux-amd64.zip' | xargs wget -O ngrok.zip
Step 5: Unzip the Downloaded File
Once the download is complete, extract the contents of the ZIP file:
unzip ngrok.zip
If you encounter an error indicating that the file is not a valid zip file, ensure that the download was completed successfully. You can check the file type with:
file ngrok.zip
It should report that it is a "Zip archive data".
Step 6: Move Ngrok to Your Local Bin Directory
After successfully unzipping, move the Ngrok binary to your local bin directory to make it executable from anywhere:
sudo mv ngrok /usr/local/bin
Step 7: Authenticate Your Ngrok Account
To use Ngrok, you will need to authenticate with your Ngrok token. Sign up at ngrok.com if you don’t already have an account. After logging in, copy your authentication token and run:
ngrok authtoken <your_auth_token>
Replace <your_auth_token>
with the actual token you received from your Ngrok dashboard.
Step 8: Start Using Ngrok
You can now start using Ngrok to expose your local server to the internet. For instance, if you have a Django application running on port 8000, you can use:
ngrok http 8000
This command will provide you with a public URL that tunnels to your local server.
Additional Information
- Once Ngrok is running, you can access the web interface at
http://127.0.0.1:4040
to monitor requests and inspect traffic. - Ensure that your local server (e.g., Django or Flask) is running before starting Ngrok.
Troubleshooting
If you encounter issues during installation:
- Check your internet connection to ensure it is stable.
- Verify that you have enough disk space on your system.
- If downloads repeatedly fail, consider downloading the Ngrok executable from another machine and transferring it to your WSL environment.
Posted on November 29, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.