Stop sharing a port on Ngrok

The Ngrok documentation mentions this example to share a local port on Internet. Example: Open port 80 on your local machine to the internet

$ ngrok 80

How do I stop sharing this port if I would not want it to be accessed on the internet any more>

12 Answers

On windows machine go to command prompt:

taskkill /f /im ngrok.exe

killall ngrok from a script or the command line will kill all running ngrok tunnels that are running.

This is what worked for me. Ty @kkron.

First, you have to find the ngrok process id by $ top command.
After that, just run $ kill -9 {ngrok_id}
That's all :)

Stopping the ngrok port/tunnel

Simple Solution

  1. If you are running ngrok normally, then use Ctrl+C (On Windows) or Cmd+C (On Mac) in ngrok command line. (Check below if issue still persist)

Extended Solution

  1. If the port does not stop/close normally or there are active ngrok sessions that are not responding, then use: killall ngrok
  2. If the above does not work or the port is still running,
  • Fix ngrok in your system by setting up your auth code again by logging into
  • Generate a new token on the dashboard (scroll down dashboard) to
  • Click on "reset authtoken", copy the auth-code, then go-to ngrok on command-line ngrok authtoken INSERT-YOUR-NEW-TOKEN-HERE
  • Then go to ngrok folder or use command line to delete the .ngrok configuration file and directory: ngrok.yml, to remove the old configuration effectively ending all the open ports, tunnels and sessions.

Simple as pressing ctrl+c. But I'm not sure if it closes any ports. The same happens as @user7032676 told.enter image description here

Quick search process with grep

top | grep "ngrok"

My id was this, make sure to change with yours

kill -9 55636

If you like start again tunneling from working directory

ngrok http 3000

You just have to stop ngrok for this.

4

I've figured out another simple solution.

Just go to your ngrok dashboard-> Tunnels-> Agents.

Then click on the agent you want to stop and stop it from there.

Or you could restart the agent from there, which will trigger a terminal session to open on your laptop. You can now use cmd+c to quit that session and that will stop the tunnel

You should see (CTRL+C to quit) on the top right corner of your terminal, when you are running a ngrok session (Online).

Although in my case, CTRL+C wasn't working. Instead CTRL+ALT+C did the quitting for me.

Operating System: Ubuntu 20.04

For some reason whenever I launched the ngrok agent on windows, the terminal will shutdown and not stay open. I would have to go to the website to see the url for the website. To shut it down I could not do ctrl-c. I simply went into task manager and deleted the process. To access the task manager on windows do ctrl + alt + delete

There is a way to stop ngrok tunnel without killing the process directly. You can use ngrok agent api:

Just send DELETE request to

curl -X DELETE 

You can get information about running tunnels using api too. For example,

curl 

will return list of running tunnels

Reboot the computer and all. Hope helped

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like