Repository navigation
Description
Add client-side local TCP forwarding
Would it make sense for Tailcat to support exposing a served remote port as a local loopback TCP listener?
Tailcat currently supports connecting to a remote served port through stdin/stdout:
tailcat <token> 8080and applications with SOCKS support can use:
tailcat socks <token> <command>For applications that cannot use Tailcat's stdio or SOCKS proxy modes, it would be useful to expose a served remote port as an ordinary local TCP listener.
Following the existing CLI style, perhaps something like:
tailcat forward <token> 8080which would mean:
127.0.0.1:8080 -> Tailcat -> remote localhost:8080
and optionally:
tailcat forward <token> 3000:8080for:
127.0.0.1:3000 -> Tailcat -> remote localhost:8080
This would be useful for tools that expect to connect to a normal host:port and do not provide SOCKS or stdio proxy integration. Some examples are:
- database clients and GUI tools connecting to PostgreSQL, MySQL, Redis, etc.
- IDE extensions or development tools that only accept a hostname and port
- local applications that need to reach a remote development server or admin interface
- legacy or third-party software where proxy configuration is unavailable or difficult
- scripts and test environments that expect a service to exist on
localhost
For example:
tailcat forward home.example.com 15432:5432
psql -h 127.0.0.1 -p 15432or:
tailcat forward home.example.com 3000:8080after which any application can use:
http://127.0.0.1:3000
without needing Tailcat-specific support.
This can currently be approximated with socat by having it execute tailcat <token> <port> for each accepted connection, but that requires an external dependency and starts a new Tailcat client for each connection.
A native implementation could keep one Tailcat client alive and call DialTCPPort for each accepted local connection.
Does client-side local forwarding fit the intended scope of the project? Happy to work on an implementation if so.
Activity
Audi-dask commentedon Aug 31, 2026
Same need here. I implemented it as a standalone tool (not a fork of tailcat) that reuses tailcat's public API —
Client.DialTCPPort+ProxyConns— so a served remote port becomes a plain local TCP listener:Repo: https://github.com/Audi-dask/tailcat-forward (single
main.go, depends ongithub.com/tailscale/tailcat v0.3.0)I'd be happy to contribute a
forwardsubcommand to tailcat itself if that fits the project's scope.erikboberg commentedon Sep 1, 2026
I would also like this feature to be implemented, it would fit my usecase perfectly!
harrisonhjones commentedon Sep 1, 2026
If I could throw my 2 cents in: I would also love to be able to forward multiple ports in a single go. Similar to how you can serve multiple ports today. Essentially I want to be able to connect to multiple remote services as if they were on localhost. I realize you can run multiple versions of
tailcat-forward(which is what I'm playing with now) but a built-in solution would be nice.Audi-dask commentedon Sep 1, 2026
Thanks for the feedback! Just to clarify — tailcat-forward can already forward multiple ports in a single process, so you shouldn't need to run multiple instances. It reuses one tailcat client for all of them:
Each port gets its own local listener, and all connections share the same client (one handshake / NAT traversal). One thing to keep in mind: this only covers ports the server has already exposed — so you'd serve them all in one go on that side first, e.g.
tailcat serve 3306,6379,8080, and the multi-port forward on the client just mirrors that.That said, I totally agree a built-in solution would be nicer than a separate tool, and I'd be happy to help add a
tailcat forwardsubcommand if the maintainers are open to it.harrisonhjones commentedon Sep 1, 2026
🤦🏻 thanks for clarifying! I should have checked the docs. Thanks for writing such a useful tool.
cfullelove commentedon Sep 2, 2026
Given how
tailcat serve exit-nodeworks, it would be useful to specify arbitrary remote targets. This would provide functionality similar to an SSH local port forward:-L [bind_address:]local_port:remote_host:remote_portAudi-dask commentedon Sep 2, 2026
I experimented with this idea on top of the still-pending
tailcat forwardwork in #62.In my fork, I extended the proposed
forwardcommand to accept an arbitrary remote target:This creates a local listener on
127.0.0.1:13306and forwards connections to192.168.1.10:3306from the Tailcat server's network.The prototype accepts these mapping formats:
For the arbitrary-target form, the client uses
Client.DialTCP, while the existingOnTCPForwardhandler on a server running inexit-nodemode establishes the connection to the target.I also tested it against a service at
10.11.1.96:3100:Accessing
http://127.0.0.1:3100/metricssuccessfully returned the remote service's metrics.The experimental implementation is available here:
https://github.com/Audi-dask/tailcat/tree/forward-exit-node
This builds on the proposed
forwardcommand from #62, which has not been merged upstream.The current prototype uses a separate
--bindflag for the local bind address:So it provides behavior similar to SSH
-L, but does not exactly copy the SSH command-line syntax.I wanted to share the prototype and validation results in case they are useful for discussing the design. Feedback on the mapping syntax and overall approach would be appreciated.