ngrok Agent Command Line Interface (CLI)
The ngrok agent CLI offers built-in commands for interfacing with the ngrok API. These API commands have been separated into the ngrok agent CLI API page for convenience. For more information about the ngrok API and interfacing with it directly, see see the ngrok api page.
ngrok
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/obs/traffic-inspector to inspect traffic.
Usage
ngrok [command] [flags]
Example
ngrok http 80 # secure public URL for port 80 web server
ngrok http --url baz.ngrok.dev 8080 # port 8080 available at baz.ngrok.dev
ngrok http foo.dev:80 # tunnel to host:port instead of localhost
ngrok http https://localhost # expose a local https server
ngrok tcp 22 # tunnel arbitrary TCP traffic to port 22
ngrok tls --url=foo.com 443 # TLS traffic for foo.com to port 443
ngrok start foo bar baz # start tunnels from the configuration file
SubCommands
Command | Description |
---|---|
api | use ngrok agent as an api client |
completion | generates shell completion code for bash or zsh |
config | update or migrate ngrok's configuration file |
credits | prints author and licensing information |
diagnose | diagnose connection issues |
http | start an HTTP tunnel |
service | run and control an ngrok service on a target operating system |
start | start endpoints or tunnels by name from the configuration file |
tcp | start a TCP tunnel |
tls | start a TLS tunnel |
tunnel | start a tunnel for use with a tunnel-group backend |
update | update ngrok to the latest version |
version | print the version string |
Flags
Flag | Description |
---|---|
--metadata | opaque user-defined metadata for the tunnel session |
ngrok completion
The ngrok 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
. <(ngrok completion)
To enable them each time you start a new session, add the following to your .bashrc
or .zshrc
files:
if command -v ngrok &>/dev/null; then
eval "$(ngrok completion)"
fi
Once you add this to your profile, you'll need to source ~/.bashrc
or source ~/.zshrc
to enable it for your current session.
Usage
ngrok completion [flags]
Example
Flags
Flag | Description |
---|---|
--config | path to config files; they are merged if multiple |
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
Command | Description |
---|---|
add-api-key | save api key to configuration file |
add-authtoken | save authtoken to configuration file |
add-connect-url | adds the connect URL (connect_url) to configuration file for custom agent ingress |
add-server-addr | alias of add-connect-url |
check | check configuration file |
edit | edit configuration file |
upgrade | auto-upgrade configuration file |
Flags
Flag | Description |
---|---|
--config | path to config files; they are merged if multiple |
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
ngrok config add-api-key TOKEN [flags]
Example
ngrok config add-api-key 1roPsn7AascHeO18mHcxRD3xT76_3ww7C9CDLYNgcdSYsscCB
Flags
Flag | Description |
---|---|
--config | save in this config file |
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. In order 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
ngrok config add-authtoken TOKEN [flags]
Example
ngrok config add-authtoken 1rlHSX3HqrqmOWZdeJ6bIv8rfuo_4cmS1QswRGyxcQD8NOukF
Flags
Flag | Description |
---|---|
--config | save in this config file |
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
ngrok config add-connect-url agent.example.com:443 [flags]
Example
ngrok config add-connect-url agent.example.com:443
Flags
Flag | Description |
---|---|
--config | save in this config file |
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
ngrok config add-server-addr agent.example.com:443 [flags]
Example
ngrok config add-server-addr agent.example.com:443
Flags
Flag | Description |
---|---|
--config | save in this config file |
ngrok config check
Checks a configuration file for validity/correctness.
Usage
ngrok config check [flags]
Flags
Flag | Description |
---|---|
--config | check this config file |
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
ngrok config edit [flags]
Flags
Flag | Description |
---|---|
--config | check this config file |
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
ngrok config upgrade [version] [flags]
Flags
Flag | Description |
---|---|
--config | upgrade this config file |
--dry-run | preview the proposed changes |
--relocate | relocates the config file to the default location |
ngrok credits
Displays program credits and license information.