·7 min read

Local Port Forwarding: Access Remote Services as If They Were Local

Need to access a database, admin panel, or API running on a remote server? FoxTerm's local port forwarding creates secure tunnels so you can connect from localhost — no VPN required.

Port ForwardingTunnelingSecurityNetworkingProductivity

Imagine this scenario: You have a PostgreSQL database running on a production server. It's bound to localhost:5432 for security — not exposed to the public internet. How do you connect to it from your local development machine?

Option 1: Temporarily modify the server's firewall rules (risky).
Option 2: Set up a VPN (overkill for a one-off task).
Option 3: Use SSH local port forwarding (the right way).

FoxTerm makes option 3 effortless.

What Is Local Port Forwarding?

Local port forwarding creates a secure tunnel through your SSH connection:

Local Machine          SSH Tunnel           Remote Server
┌─────────────┐                           ┌──────────────────┐
│             │   Encrypted SSH Connection │                  │
│ localhost   │◄─────────────────────────►│ Remote Service   │
│ :8080       │                           │ :5432            │
└─────────────┘                           └──────────────────┘

You connect to localhost:8080 on your Mac, and the traffic is forwarded through SSH to remote-server:5432.

FoxTerm's Implementation

FoxTerm uses Apple's Network framework (NWListener) combined with libssh's forwarding API to create robust, high-performance tunnels.

TCP Forwarding

Forward any TCP port:

# Traditional SSH command
ssh -L 8080:localhost:5432 user@server

# FoxTerm: Just click "Forward Port" in the UI

Use cases:

  • Database access — Connect local pgAdmin/DBeaver to remote databases
  • Admin panels — Access web interfaces bound to localhost
  • APIs — Test internal APIs from your local environment
  • Redis/MongoDB — Connect local clients to remote instances

Unix Socket Forwarding

This is where FoxTerm gets interesting. It can forward Unix domain sockets:

# Forward remote Docker socket to local path
ssh -L /var/run/docker.sock:/var/run/docker.sock user@server

# Now local Docker CLI manages remote containers
docker ps  # Shows containers on the remote server!

This enables powerful workflows:

  • Remote Docker management — Use local Docker CLI to control remote daemons
  • Systemd socket access — Interact with systemd services remotely
  • Application sockets — Connect to apps that expose Unix sockets

Bidirectional Streaming

FoxTerm implements bidirectional stream bridging with 64KB buffers for maximum throughput. Data flows seamlessly in both directions:

  • Local → Remote: Your requests reach the remote service
  • Remote → Local: Responses return to your local client

No buffering delays, no connection drops.

Multiple Forwards

Create multiple forwarding rules simultaneously:

  • Forward localhost:8080 → remote:80 (web server)
  • Forward localhost:5432 → remote:5432 (PostgreSQL)
  • Forward localhost:6379 → remote:6379 (Redis)

Manage all forwards from a single interface. Enable/disable individually without reconnecting.

Security Benefits

Encryption

All forwarded traffic is encrypted within the SSH tunnel. Even on public Wi-Fi, your database credentials and API tokens are safe.

No Firewall Changes

Since the connection originates from inside the server (via SSH), you don't need to open inbound ports. The server's firewall remains locked down.

Temporary Access

Forwards exist only while the SSH session is active. Disconnect, and the tunnel closes automatically. No lingering exposure.

Use Cases

Database Administration

Connect local database tools (TablePlus, Postico, DBeaver) to remote databases without exposing them to the internet.

Web Development

Access staging environments bound to localhost. Test APIs, debug webhooks, or preview internal dashboards.

Microservices Debugging

Forward ports to individual microservices running on remote Kubernetes nodes or Docker Swarm clusters.

IoT Device Management

SSH into a gateway device, then forward ports to IoT devices on the local network that aren't directly accessible.

CI/CD Pipeline Testing

Forward ports to CI runners to test deployment scripts or inspect build artifacts.

Advanced Features

Automatic Reconnection

If the SSH connection drops, FoxTerm attempts to re-establish forwards automatically. No manual intervention needed.

Traffic Statistics

Monitor bytes sent/received through each forward. Identify high-bandwidth tunnels or unexpected activity.

Custom Bind Addresses

Bind forwards to specific interfaces:

  • localhost — Only accessible from your Mac
  • 0.0.0.0 — Accessible from other devices on your network (use with caution)

The Bottom Line

Local port forwarding is one of SSH's most powerful features — and FoxTerm makes it accessible to everyone. No command-line memorization, no complex configuration. Just point, click, and connect.


Download FoxTerm at foxterm.app.