Skip to main content
TCP endpoints enable you to deliver any network service with a TCP-based protocol. They’re commonly used to create connectivity for:
  • Remote access protocols like SSH, VNC, and RDP
  • Databases like MySQL, Postgres, MSSQL, and SQLite
  • IoT protocols like MQTT
  • Gaming servers like Minecraft
If you’re accepting TLS traffic, you may prefer to create a TLS Endpoint.
TCP endpoints are only available on a free plan after adding a valid payment method to your account.

Quickstart

Agent Endpoints are the easiest way to get started with ngrok. A Secure Tunnels agent starts an Agent Endpoint. The endpoint lives for the lifetime of the process and forwards traffic to a port or URL of your choosing. This example creates a TCP endpoint on a randomly assigned URL—for example, tcp://1.tcp.ngrok.io:12345—and forwards its traffic to a local port.

URLs

ngrok validates URLs differently depending on their binding. Consult the following documentation for details on valid URLs for TCP endpoints: There is no standard scheme for TCP URLs, so ngrok renders them as tcp://.

Static URLs

To give a public TCP endpoint a static URL, first create a TCP Address. When you create a TCP address, ngrok assigns you a random hostname and port, for example, 1.tcp.ngrok.io:12345. You only need a TCP address to make a public TCP endpoint have a static URL. You don’t need one for TCP endpoints on other bindings, like internal or kubernetes. After you create a TCP Address, specify the address (for example, 1.tcp.eu.ngrok.io:12345) in the URL when you create the endpoint.

Custom domains

ngrok assigns public TCP endpoints a random ngrok-controlled hostname and a random port. You can’t choose the hostname or the port. However, you can simulate a customized hostname by creating a CNAME record to the hostname of your assigned TCP address. If you do so, be aware that all ports on that hostname, even those provisioned to other accounts, are then available on your domain. For example, if your TCP address is 5.tcp.ngrok.io:12345, you can create the following CNAME record:
Then you can access that TCP endpoint with:

Traffic Policy

Attach Traffic Policy to endpoints to route, authenticate, and transform the traffic through the endpoint.

Authentication

When you create public TCP endpoints, you often want to secure them with authentication. You can secure your TCP endpoints with the following Traffic Policy actions. There is a limited set of actions available to authenticate TCP traffic because the TCP protocol is low-level.

Agent forwarding

The ngrok agent and Agent SDKs forward traffic that your endpoints receive to upstream services. You specify a URL or port number to instruct the ngrok agent where and how to forward traffic.

Forward to non-local service

Agents don’t just forward to ports on your localhost. You can forward traffic to any address or URL reachable from the agent. For example, to forward traffic to a Postgres server running on your network at 192.168.1.2:5432:

PROXY protocol

When you forward traffic to an upstream TCP service, it doesn’t know the client’s original IP address because the traffic comes from the ngrok agent. You can add the PROXY protocol header on connections to your upstream service to send connection information like the original client IP address to your upstream service. You need to configure your upstream service to handle the PROXY protocol header.

Observability

Traffic Inspector

The TCP tab in Traffic Inspector lists each connection to your TCP endpoint after it closes, including client IP, duration, bytes transferred, and any ngrok error.

Log exports

You can export logs of traffic to TCP endpoints with ngrok’s events system. ngrok publishes the following events for log exporting:

Limits & timeouts

Contact Support if you need to configure limits and timeouts on connections to TCP endpoints.

Errors

If ngrok encounters an error while handling connections to a TCP endpoint for any reason (for example, a Traffic Policy action error or an internal server error), it closes the connection. Because of the low-level nature of the TCP protocol, there is no mechanism to transmit information about what error code ngrok encountered. Use the observability features to understand connection handling errors.

API

You can create TCP Endpoints programmatically. Consult the documentation on Endpoint APIs.

TCP endpoint pricing

TCP endpoints are available on all plans. Consult the Endpoints Pricing documentation for billing details. TCP endpoints are only available on a free plan after adding a valid payment method to your account. See TCP Addresses pricing for details on pricing for fixed TCP Addresses.