> Markdown version of https://tuna.am/en/docs/tunnels/migrate/ngrok/. Documentation index: [llms.txt](https://tuna.am/en/llms.txt), full text in one file: [llms-full.txt](https://tuna.am/en/llms-full.txt). Any page is available as Markdown: append `.md` to its URL without the trailing slash.

# Migrating from ngrok

tuna commands work almost the same way as ngrok's: `ngrok http 8080` becomes `tuna http 8080`. Below is what changes in signing in, addresses, flags and the config file.

If ngrok stopped working in Russia with the [ERR_NGROK_9040](https://tuna.am/en/blog/err-ngrok-9040.md) error, everything you need to switch is on this page:

```text
ERROR:  authentication failed: We do not allow agents to connect to ngrok from your IP address (198.51.100.55).
ERROR:  ERR_NGROK_9040

```

## Installing and signing in

Install tuna by following the [instructions](https://tuna.am/en/docs/guides/install/install-cli.md) and sign in:

```shell
tuna login

```

A browser opens, and once you confirm, the CLI stores the session in the system keyring. There's no `authtoken` in a config file.

| ngrok                                | tuna           |
| ------------------------------------ | -------------- |
| `ngrok config add-authtoken <token>` | `tuna login`   |
| `NGROK_AUTHTOKEN`                    | `TUNA_API_KEY` |
| `--authtoken`                        | `--api-key`    |

In CI, Docker and on servers without a browser, use an [API key](https://my.tuna.am/api_keys?lang=en) with "Run tunnels" enabled. See [Sessions and API keys](https://tuna.am/en/docs/guides/sessions-and-api-keys.md) for details.

## Commands

| ngrok                                      | tuna                                     |
| ------------------------------------------ | ---------------------------------------- |
| `ngrok http 8080`                          | `tuna http 8080`                         |
| `ngrok http file:///var/www`               | `tuna http -f /var/www`                  |
| `ngrok tcp 5432`                           | `tuna tcp 5432`                          |
| `ngrok start web`                          | `tuna start web`                         |
| `ngrok start --all`                        | `tuna start --all`                       |
| `ngrok service install --config ngrok.yml` | `tuna service install -- tuna http 8080` |
| `ngrok update`                             | `tuna update`                            |

For databases and SSH, tuna has dedicated commands with a protocol-aware inspector: [`tuna postgres`](https://tuna.am/en/docs/tunnels/postgres.md), [`tuna mysql`](https://tuna.am/en/docs/tunnels/mysql.md), [`tuna redis`](https://tuna.am/en/docs/tunnels/redis.md), [`tuna ssh`](https://tuna.am/en/docs/tunnels/ssh.md). `tuna tcp` works for any TCP service.

## Addresses

| ngrok                                       | tuna                                                                                                                                         |
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Random address                              | [Dynamic address](https://tuna.am/en/docs/tunnels/http.md#dynamic) in the `a.2na.am` zone                                                    |
| Free static domain                          | [Free permanent subdomain](https://tuna.am/en/docs/tunnels/http.md#free-subdomain) in the `a.tuna.free` zone: `--subdomain=<your-subdomain>` |
| `--url https://myapp.ngrok.app`             | [Reserved subdomain](https://tuna.am/en/docs/tunnels/http.md#reserved-subdomain): `--subdomain=myapp`                                        |
| `--url https://app.example.com`             | [Custom domain](https://tuna.am/en/docs/tunnels/http.md#custom-domain): `--domain=app.example.com`                                           |
| `ngrok tcp --url=1.tcp.ngrok.io:27210 3389` | [Reserved port](https://tuna.am/en/docs/tunnels/ports.md): `tuna tcp 3389 --port=rdp`                                                        |

TCP tunnels and reserved subdomains require a [subscription](https://tuna.am/#pricing); the free permanent subdomain is available on every plan.

On the free plan, browsers see a [warning page](https://tuna.am/en/docs/troubleshooting/errors/browser-warning.md) in front of the tunnel, just as with ngrok. To keep it away from your frontend, send the `tuna-skip-browser-warning` header instead of `ngrok-skip-browser-warning`.

Add your own domain in the [dashboard](https://my.tuna.am/domains?lang=en) first and point it to us with a CNAME record. Step by step: [Connecting your own domain](https://tuna.am/en/docs/tunnels/guides/connect-self-domain.md).

There's no `--region` flag: you don't need to pick a region.

## Access control

ngrok has deprecated many of its access flags in favor of Traffic Policy. In tuna they're still flags:

| ngrok                                         | tuna                                                                                                    |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `--basic-auth user:pass`                      | [`--basic-auth=user:pass`](https://tuna.am/en/docs/tunnels/http.md#basic-auth)                          |
| `--cidr-allow`, `--cidr-deny`                 | [`--cidr-allow`, `--cidr-deny`](https://tuna.am/en/docs/tunnels/http.md#cidr)                           |
| `--ua-filter-allow`, `--ua-filter-deny`       | [`--ua-allow`, `--ua-deny`](https://tuna.am/en/docs/tunnels/http.md#user-agent)                         |
| `--verify-webhook`, `--verify-webhook-secret` | [`--verify-webhook`, `--verify-webhook-secret`](https://tuna.am/en/docs/tunnels/http.md#verify-webhook) |
| `--request-header-add`                        | [`--request-header`](https://tuna.am/en/docs/tunnels/http.md#request-header)                            |
| `--response-header-add`                       | [`--response-header`](https://tuna.am/en/docs/tunnels/http.md#response-header)                          |
| `--oauth`, `--oidc`                           | [Apps](https://tuna.am/en/docs/apps.md): SSO sign-in in front of the service                            |
| `--traffic-policy-file`                       | [`--policy-file`](https://tuna.am/en/docs/traffic-policy.md)                                            |

tuna [traffic policies](https://tuna.am/en/docs/traffic-policy.md) are similar to Traffic Policy: a rule consists of expressions and actions — `basic_auth`, `restrict_ips`, `rate_limit`, `redirect`, `url_rewrite`, `add_headers`, `custom_response` and others. The expression syntax and action names differ, so you'll have to rewrite your policy file.

## Config file

`ngrok.yml` describes the agent and a list of endpoints. In tuna, this is split into two files:

* the global `tuna.yml` stores the API key and proxy settings; its location is on the [Configuration File](https://tuna.am/en/docs/guides/config-file.md) page;
* `.tuna.yml` in the project root describes tunnels and traffic policies, and you can commit it to the repository.

Before, in `ngrok.yml`:

ngrok.yml

```yaml
version: 3
agent:
  authtoken: <token>
endpoints:
  - name: web
    url: https://web.ngrok.app
    upstream:
      url: 3000
  - name: db
    url: tcp://1.tcp.ngrok.io:27210
    upstream:
      url: 5432

```

After, in `.tuna.yml`:

.tuna.yml

```yaml
tunnels:
  web:
    commandLine: tuna http 3000 --subdomain=web
  db:
    commandLine: tuna tcp 5432 --port=db

```

Start them with `tuna start web` or `tuna start --all`. You can tag tunnels and start them as a group; see [Multiple Tunnel Startup](https://tuna.am/en/docs/tunnels/guides/multi-tunnels.md) for details.

## Inspector

The Request Inspector also opens at `http://127.0.0.1:4040`; further tunnels get 4041, 4042 and so on. Request replay is there too.

| ngrok                      | tuna                                                                     |
| -------------------------- | ------------------------------------------------------------------------ |
| `--inspect=false`          | [`--inspect=false`](https://tuna.am/en/docs/tunnels/inspect.md#disable)  |
| `web_addr: 127.0.0.1:4100` | [`--inspect-port=4100`](https://tuna.am/en/docs/tunnels/inspect.md#port) |

Besides HTTP, the [inspector](https://tuna.am/en/docs/tunnels/inspect.md) shows queries to PostgreSQL, MySQL and Redis.

## Running in the background and Docker

`ngrok service install` runs all the tunnels from the config. In tuna, each [service](https://tuna.am/en/docs/tunnels/guides/service.md) runs one tunnel command and has its own name:

```shell
tuna service install --name=web -- tuna http 3000 --subdomain=web
tuna service install --name=db -- tuna tcp 5432 --port=db

```

The Docker image is `yuccastream/tuna`; the container arguments are the tuna command:

```shell
docker run -d --network host -e TUNA_API_KEY=<your_key> yuccastream/tuna http 3000

```

See [Containers](https://tuna.am/en/docs/guides/install/install-containers.md) for details.

If you started tunnels from code with the ngrok SDK, tuna has [SDKs](https://tuna.am/en/docs/guides/install/sdk.md) for Go, Node.js, Python, Java, .NET, PHP, Ruby and Rust.

## What tuna doesn't have

* There's no equivalent of `ngrok tls`: tuna doesn't route TLS traffic by hostname without decrypting it. If your service has to hold the certificate itself, use `tuna tcp` — the address will include a port.
* Neither ngrok nor tuna supports UDP.

## Next steps

* [HTTP tunnel](https://tuna.am/en/docs/tunnels/http.md): all flags and examples.
* [Error catalog](https://tuna.am/en/docs/troubleshooting/errors.md): what a CLI message means and how to fix it.
* [Pricing](https://tuna.am/#pricing): what's free and what needs a subscription.
