ngrok Command Line Interface (CLI)
The ngrok CLI offers built-in commands for interfacing with the ngrok API. These API commands have been separated into the ngrok CLI API page for convenience. For more information about the ngrok API and interfacing with it directly, see the ngrok api page.ngrok
ngrok puts network services, apps and APIs online. ngrok exposes local networked services behinds NATs and firewalls to the public internet over a secure tunnel. Share local websites, build/test webhook consumers and self-host personal services. Detailed help for each command is available by adding ‘—help’ to any command or with the ‘ngrok help’ command. Open https://dashboard.ngrok.com/traffic-inspector to inspect traffic through your endpoints.Usage
Example
SubCommands
Flags
ngrok completion
Thengrok completion command generates shell tab completion code for Bash or Zsh. This requires bash-completion or zsh-completions packages to be enabled in your shell.
You can add it to your current session with the command
.bashrc or .zshrc files:
source ~/.bashrc or source ~/.zshrc to enable it for your current session.
Usage
Example
Flags
ngrok config
The config command gives a quick way to create or update ngrok’s configuration file. Use ‘add-authtoken’ or ‘add-api-key’ to set the corresponding properties. Use ‘check’ to test a configuration file for validity. If you have an old configuration file, you can also use ‘upgrade’ to automatically migrate to the latest version.SubCommands
Flags
ngrok config add-api-key
The add-api-key command modifies your configuration file to include the specified api key. The API key can be generated in the API section of the ngrok dashboard.Usage
Example
Flags
ngrok config add-authtoken
The add-authtoken command modifies your configuration file to include the specified authtoken. ngrok requires that you sign up for an account to use many advanced service features. In order to associate your client with an account, it must pass a secret token to ngrok when it starts up. Instead of passing this authtoken on every invocation, you may use this command to save it into your configuration file so that your client always authenticates you properly. Additionally, this command saves the default config version, providing a working config file out of the box. You can find your authtoken in the getting started section of the ngrok dashboard. The ngrok service requires that you sign up for an account to connect with an agent. Some advanced service features require a paid account. To associate your agent with an account, it must pass a secret token to the ngrok service when it starts up. Instead of passing this authtoken on every invocation, you may use this command to save it into your configuration file so that your agent always authenticates you properly.Usage
Example
Flags
ngrok config add-connect-url
The add-connect-url command modifies your configuration file to include the specified connect URL (connect_url) used for custom agent ingress.Usage
Example
Flags
ngrok config add-server-addr
The ngrok config add-server-addr command updates the server address (server_addr) in the configuration file. This is useful when your account is using Custom Agent Ingress and you need to configure the server_addr to point to your new ingress domain. See Also:server_addr
Custom Agent Ingress
Usage
Example
Flags
ngrok config check
Checks a configuration file for validity/correctness.Usage
Flags
ngrok config edit
Opens the configuration file in an editor defined by the EDITOR environment variable, defaulting to nano or Notepad depending on OS.Usage
Flags
ngrok config upgrade
Upgrade a configuration file to a version. A backup file will be created with your original configuration file in the same directory. You can optionally pass a version to upgrade to. If the configuration file version is missing, the upgrade command will add it. It also applies all automatic transformations when upgrading versions. Attempting to downgrade will result in an error. By default this command will apply the transformations and display the final file. Use —dry-run to preview changes before applying. By default this command will not move any configuration files to their new default location. Use —relocate to move the config file to the default location.Usage
Flags
ngrok credits
Displays program credits and license information.Usage
Flags
ngrok diagnose
Run tests to diagnose issues establishing connectivity to the ngrok cloud service. Exits 0 if connectivity is OK, otherwise 1. OPTIONS: —config strings path to config files; they are merged if multiple -h, —help help for diagnose -6, —ipv6 Enable testing of IPV6 addresses -r, —region string ngrok server region [auto, us, eu, au, ap, sa, jp, in, us-cal-1, eu-lon-1, all] -w, —write-report string Write a JSON reportUsage
Flags
ngrok http
Forward HTTP traffic from an ngrok endpoint URL to a local port, address or URL. The ngrok agent creates secure TLS connections to the ngrok cloud gateway over which it creates an endpoint with a URL and forwards traffic received on that URL over the TLS connections to the agent and then on to your local service. Specify a Traffic Policy to configure the ngrok cloud service to apply auth, routing, security or other handling of the incoming HTTP traffic. If you are not forwarding traffic to an http(s) server, usengrok tcp or ngrok tls instead.
Usage
Example
Flags
ngrok service
The service command manages installation and execution of ngrok as an operating system service on Windows, OS X and Linux systems. The service command takes a single argument which must be ‘start’, ‘stop’, ‘restart’, ‘install’, or ‘uninstall’. When you choose ‘install’, you must specify the config flag which will define where the installed ngrok service looks for its configuration file. When the ngrok service runs, it has the same behavior as if it were invoked from the command line with the command: “ngrok start —all”. For more information about running ngrok as a service, check out the ngrok service section in the secure tunnels documentationUsage
Example
Flags
ngrok start
start - start endpoints by name from the configuration fileUsage
Example
Flags
ngrok tcp
Starts a tunnel which forwards all TCP traffic on a public port to a local address. This is extremely useful for exposing services that run non-HTTP traffic (ssh, sip, rdp, game servers, etc). A TCP tunnel binds a public address on the remote ngrok server. Any services which require a stable public address should use the —url option. ngrok requires that you reserve a TCP tunnel address for your account before you can use it.TCP endpoints are only available on a free plan after adding a valid payment method to your account.