Tsallake zuwa abun ciki
Localtonet Localtonet Dashboard

Wannan shafin bai samu a cikin Hausa tukuna ba. Ana nuna shi da Turanci.

Expose a TCP service

Taimako kan wannan shafi
A wannan shafin 8 sassa
  1. Before you start
  2. Steps
  3. Open the TCP - UDP page
  4. Fill in the form
  5. Start the tunnel
  6. Connect to the endpoint
  7. The endpoint: host name and server port
  8. Reserved port
  9. Choose your own server port
  10. Tunnel IP
  11. Settings of a TCP tunnel
  12. Proxy Protocol
  13. Examples
  14. SSH
  15. A database
  16. More services
  17. On the Free plan
  18. Troubleshooting
  19. Related pages

A TCP tunnel gives a local TCP service, such as SSH, a database or a game server, a public host name and port. You create it on the TCP - UDP page, which also holds the UDP and UDP - TCP tunnels.

Before you start #

  • The Localtonet client is installed on the device and connected with an AuthToken. If it is not, follow the Quick start.
  • The service is running and you know its port, for example 22 for SSH.
  • For a custom subdomain, a reserved port or a server port of your choice: Balance on your account.

A new tunnel is publicly reachable. Anyone who has the address can connect to the port. Keep strong authentication on the service, and consider an IP restriction, which needs Balance.

Steps #

  1. Open the TCP - UDP page #

    Open My Tunnels › TCP - UDP and select Create TCP - UDP Tunnel to open the form.

  2. Fill in the form #

    FieldWhat to enter
    ProtocolTCP. The other choices are UDP and UDP - TCP.
    Device tokenThe token used by the Localtonet app on your device.
    Server regionChoose a region close to your device for lower latency.
    Local IP addressAddress of the service on your device. Use 127.0.0.1 for this device, or the address of another machine in your network.
    Local portThe port your local service listens on, from 1 to 65535.
    URL typeRandom subdomain generates the host name. Custom subdomain lets you type it in Subdomain and needs Balance.
    Domainlocalto.net, or a domain you added in DNS Manager.

    Select Create tunnel. The tunnel appears under Your tunnels.

  3. Start the tunnel #

    Select the start button in the Actions column. Localtonet assigns a server port when the tunnel starts. Until then the Server Port column shows a dash.

  4. Connect to the endpoint #

    The URL column shows the endpoint as host name and port, for example <SUBDOMAIN>.localto.net:<SERVER_PORT>. Select it to copy it. Use this host and port in your client instead of the local address.

The endpoint: host name and server port #

A TCP tunnel has two ports. The local port is where your service listens on your device. The server port is the port people connect to on the Localtonet server. They do not have to be the same number.

ColumnShows
URLHost name and server port together, ready to copy.
Server PortThe server port alone, with an icon that tells whether the port is reserved.
Protocol TypeTCP, UDP or UDP_TCP.

Reserved port #

A reserved port stays the same when the tunnel or the Localtonet app restarts. A port that is not reserved changes when the tunnel or the app restarts, so the address you shared stops working.

  • With Balance, a tunnel is created with a reserved port. It keeps the port it gets at its first start.
  • On the Free plan the port is not reserved. Add Balance, then turn on Is Reserved? in the tunnel settings to keep it fixed.
  • To reserve the port of an existing tunnel, start the tunnel, then turn on Is Reserved? or select the icon next to the port and choose Reserve port. A port can only be reserved while the tunnel runs, so for a stopped tunnel the same popup offers Start to reserve, which starts the tunnel.
  • To give the port up, turn Is Reserved? off and confirm Release. The port may change after the next restart.

Choose your own server port #

In the tunnel settings, select Change next to Server Port. Enter a number from 501 to 65535. Port 4040 is not available. Saving reserves the port for this tunnel and restarts the tunnel, so the device must be online. If another tunnel on this server already uses the port, you are asked to pick another one. Changing the server port needs Balance. See Ports.

Tunnel IP #

Tunnel IP in the tunnel settings shows the IPv4 address of the server, and its IPv6 address when it has one. Clients can connect with this address instead of the host name. Server IP addresses can change, so use the host name in apps and scripts whenever you can.

Settings of a TCP tunnel #

Select the settings button in the Actions column to open the Tunnel settings panel. Under Tunnel Details you can copy the endpoint, rename the tunnel and change the local IP address and the local port.

SettingWhat it doesRead more
Is Reserved?Keep the same server port when the tunnel restarts.This page, above
Server PortChange the port clients use to connect to this tunnel.Ports
Is SslStream?The Localtonet app connects to your local service with TLS. Turn it on when the local service itself uses TLS.This page
Proxy Protocol?Pass the original client address to your service in a PROXY protocol header.This page, below
Legacy Connect?Try this if the tunnel cannot connect with the normal method.Settings reference
Tunnel IPView the IPv4 and IPv6 addresses clients use to reach this tunnel.This page, above
IP RestrictionControl which client IP addresses can access this tunnel.Access control
Expiration Date, Speed Limits, Bandwidth Limit, Bandwidth Usage, Bandwidth TrafficStop the tunnel on a date, cap its speed, cap its data, reset the data counter, and see the traffic over time.Limits and expiration
Request Log, Activity Log, Tunnel HealthSee the connections made to the tunnel, its starts, stops and setting changes, and the health checks.Logs and inspection
ArgumentsSend this tunnel through a specific network on your device.Network selection
Outbound PortUse fixed outbound ports for the Localtonet app's server connection, for strict firewalls.Ports
Tunnel NoteSave a private note to help you identify this tunnel.Settings reference
Load BalanceDistribute traffic across devices or use a backup target.Load balancing
Show SSH CommandStart this tunnel with plain SSH, without installing the Localtonet app. Offered for TCP tunnels only, not for UDP or UDP - TCP.Zero-install SSH

Changing Is SslStream?, Proxy Protocol?, Legacy Connect? or the server port on a running tunnel restarts it. The Localtonet app must be connected, otherwise you get "Check the device connection."

Proxy Protocol #

Through a tunnel, your service sees every connection arrive from the Localtonet app on your device, not from the real visitor. With Proxy Protocol? turned on, the app writes one PROXY protocol line (version 1, plain text) at the start of each connection, before the visitor's data:

First line of the connection
PROXY TCP4 <VISITOR_IP> <LOCAL_IP> <VISITOR_PORT> <LOCAL_PORT>

For an IPv6 visitor the line starts with PROXY TCP6.

Turn it on only when your service expects it. A service that does not understand the PROXY protocol treats the extra line as data and rejects the connection. Many servers have a setting for it, for example proxy_protocol in nginx and accept-proxy in HAProxy. Check the documentation of your service.

Examples #

SSH #

Create a TCP tunnel with Local IP address 127.0.0.1 and Local port 22, and start it. Connect from anywhere with the host and server port from the URL column:

Terminal
ssh -p <SERVER_PORT> <USER>@<SUBDOMAIN>.localto.net

The full guide is Using Localtonet with SSH.

A database #

Create a TCP tunnel to the port of the database, for example 5432 for PostgreSQL or 3306 for MySQL. Then use the tunnel host and server port in your database client:

PostgreSQL
psql -h <SUBDOMAIN>.localto.net -p <SERVER_PORT> -U <DB_USER> <DB_NAME>
MySQL
mysql -h <SUBDOMAIN>.localto.net -P <SERVER_PORT> -u <DB_USER> -p

The database must accept connections on the local address you entered. Guides: PostgreSQL, MySQL, SQL Server, MongoDB.

More services #

On the Free plan #

The dashboard describes the Free session limit like this: TCP/UDP, TLS, Proxy and Rotating Proxy tunnels stop after 30 minutes. To resume, select Start to begin another session if you have monthly bandwidth left, and keep your Localtonet client connected. A stopped tunnel shows Session ended in the list.

Because the port of a Free tunnel is not reserved, the server port can be different after the next start. A positive Balance removes the session limit and lets you reserve the port. See Plans and Balance.

Troubleshooting #

The client cannot connect to the endpoint

Check three things in the list. The tunnel is started. The Connection column shows ON, which means the Localtonet app is connected. The host and port in your client match the URL column: the server port changes after a restart when it is not reserved. Then make sure your service listens on the local IP address and port of the tunnel.

"The Localtonet app for AuthToken … is not connected."

Start the Localtonet client on the device with this tunnel's token. The start dialog starts the tunnel by itself as soon as the app connects.

"You need to purchase balance to use this feature."

A custom subdomain, a reserved port and a server port of your choice need Balance. Add it under Balance, or use Random subdomain and the assigned port.

"Port … is not available on this server."

Another tunnel on the same server uses or has reserved that server port. Pick another port, or move the tunnel to another server by selecting the server name in the list.

"Pick a port from 501 to 65535." or "Port 4040 is used by Localtonet. Pick another one."

Server ports below 501 and port 4040 cannot be used. Your local port can still be any port, for example 22 or 80. Only the public server port is limited.

"Port not reserved" with the button "Start to reserve"

A port can only be reserved while the tunnel runs and has a server port. Select Start to reserve to start the tunnel. When it runs, turn on Is Reserved?.

The service rejects every connection after I turned on Proxy Protocol?

Your service does not expect the PROXY protocol line. Turn the switch off, or enable PROXY protocol support in the service.

The tunnel stopped by itself

Open Activity Log in the tunnel settings. It names the reason, for example that the free usage limit was reached, that the tunnel's bandwidth limit was reached or that its expiration date passed.

Taimako