Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk12 min

How to Use SSH Port Forwarding on a Linux VPS

A practical guide to OpenSSH local, remote and dynamic forwarding on a Linux VPS, including command syntax, listener behavior, server policy, firewall exposure and fixes for common errors.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

SSH port forwarding turns an encrypted SSH session into a controlled TCP path between your computer, a Linux VPS and another service. Use -L when your computer needs to reach a service accessible from the VPS, -R when a VPS-side process must reach a service on your computer, and -D when an application should use the VPS as a SOCKS proxy. Add -N for a tunnel-only session, bind to 127.0.0.1 or ::1 by default, and change server policy only when a deliberate wider exposure is required.

How SSH forwarding maps a connection

An SSH tunnel has three separate locations that are easy to confuse:

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Listener: the address and port where an application first connects.
  • SSH transport: the encrypted connection between your SSH client and the VPS.
  • Destination connection: the TCP connection opened at the far side of the tunnel.

With local forwarding, the listener is on your computer and the destination connection is opened from the VPS side. With remote forwarding, the listener is on the VPS and the destination connection is opened from your computer. Dynamic forwarding has a listener on your computer, but the destination host and port are chosen separately for each SOCKS request.

The host name in a forwarding option is interpreted from the side that opens the destination connection, not necessarily from the machine where you type the command. For example, in -L 127.0.0.1:8080:127.0.0.1:8000, the second 127.0.0.1 means “the VPS itself,” because the VPS opens the destination connection.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Choose the forwarding mode

Mode Command pattern Listener location Where the destination connection opens Destinations Typical use
Local (-L) ssh -N -L [bind:]local_port:host:host_port user@vps SSH client VPS or another host reachable from the VPS One fixed host and port per forwarding rule Reach a private database, internal web UI or admin service through the VPS
Remote (-R) ssh -N -R [bind:]remote_port:host:host_port user@vps SSH server SSH client side One fixed host and port per forwarding rule Let a VPS-side process reach a service running on your computer
Dynamic (-D) ssh -N -D [bind:]socks_port user@vps SSH client Selected for each SOCKS request, through the VPS side Many TCP destinations, selected by the application Give a SOCKS-aware application a proxy path through the VPS

These options forward TCP streams handled by OpenSSH. They are not a promise of transparent UDP tunneling, and they do not automatically redirect every program on your operating system.

Prerequisites before opening a tunnel

  • A Linux VPS running an SSH server and a user account permitted to log in.
  • An SSH client on your workstation. OpenSSH is included with most Linux distributions and macOS; current Windows releases also provide an ssh client.
  • Network reachability from the VPS to the destination used by a local forward, or from your computer to the destination used by a remote forward.
  • Authentication that works without the tunnel first, such as an SSH key or password accepted by the server.
  • Permission to create the requested forwarding direction and listener address. Server policy and restrictions on the login key can deny forwarding even when an interactive shell works.

Test the ordinary connection before adding forwarding:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ssh user@vps

Keep the VPS host name, SSH port, login user and destination service details written down. “Local” and “remote” in the option names describe the listener side, not where the destination service physically lives.

Local forwarding with -L

Basic command

To make a service reachable on your workstation at port 8080 while the VPS can reach it at port 8000, run:

ssh -N -L 127.0.0.1:8080:127.0.0.1:8000 user@vps

Open http://127.0.0.1:8080 on your workstation. Your browser connects to the local listener; SSH carries that stream to the VPS; the VPS then connects to its own port 8000. The web service can remain bound only to the VPS loopback interface.

OpenSSH documents -L as forwarding connections to a TCP port or Unix socket on the local (client) host to a host and port on the remote side. The command above uses the common TCP form:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
-L [bind_address:]local_port:destination_host:destination_port

Reach another private machine through the VPS

The destination host does not have to be the VPS. If the VPS can reach an internal database at 10.20.0.15:5432, expose it only to your workstation:

ssh -N -L 127.0.0.1:15432:10.20.0.15:5432 user@vps

Configure your database client for host 127.0.0.1 and port 15432. The database sees a connection originating from the VPS-side network path, not directly from your workstation.

Pick a non-conflicting local port

The local port is merely the entry point on your computer and need not equal the destination port. If port 8080 is occupied, choose another value:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
ssh -N -L 127.0.0.1:18080:127.0.0.1:8000 user@vps

“bind: Address already in use” means another process already owns the listener on the side where the forward is created. Find and stop that process or select a different local port.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Allowing other machines to use a local forward

Leaving the bind address out can result in a wildcard listener, depending on the client and platform. A wildcard or public bind permits other interfaces to connect and can expose an otherwise private service. Use an explicit address such as 127.0.0.1 or ::1 unless another host genuinely needs access. If a controlled LAN exposure is required, bind to the workstation’s specific LAN address and apply host firewall rules; do not assume the SSH tunnel itself provides access control for every peer.

Remote forwarding with -R

Basic command

To let a process on the VPS reach a development server running on your computer at port 9000, run:

ssh -N -R 127.0.0.1:9000:127.0.0.1:9000 user@vps

A process on the VPS can now connect to 127.0.0.1:9000. The VPS-side listener sends traffic through SSH, and your computer opens the destination connection to its own port 9000.

-R [bind_address:]remote_port:destination_host:destination_port

This pattern is useful for a webhook receiver, a temporary demonstration site or a monitoring process that must reach a service behind your home or office network. The client-side service must be reachable from the machine running the SSH client; if it listens only on a different local interface, replace the destination host accordingly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why another machine cannot normally reach the remote listener

By default, sshd binds remote port forwardings to the loopback address. Consequently, the tunnel can work when tested on the VPS itself while a connection from another VPS interface fails. This is expected behavior, not proof that the SSH transport is broken.

To intentionally make the remote listener available beyond the VPS loopback interface, specify a bind address and ensure the server policy allows it:

ssh -N -R 0.0.0.0:9000:127.0.0.1:9000 user@vps

A wildcard bind can expose the service on every VPS interface. Prefer a specific private address when possible, and combine the change with firewall rules and authentication at the forwarded service. A public bind is never a substitute for those controls.

Understand GatewayPorts

The SSH server’s GatewayPorts setting governs whether remote forwards may bind to non-loopback addresses. Its documented default is no, which keeps remote forwards on loopback even when a client requests a broader address. Depending on policy, an administrator can permit client-selected addresses or force wildcard binding; the exact choice belongs in the VPS server configuration and should be made deliberately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Dynamic forwarding with -D (SOCKS)

Start the SOCKS endpoint

ssh -N -D 127.0.0.1:1080 user@vps

With -D, the SSH client acts as a SOCKS4/SOCKS5 server. Configure an individual application to use SOCKS host 127.0.0.1, port 1080. When that application requests a destination, the VPS-side path makes the TCP connection for that request.

Configure the application, not the whole system

A dynamic forward does not automatically proxy every program on the computer. Set the proxy in the browser, database tool, package manager or other application that supports SOCKS. If an application offers both SOCKS4 and SOCKS5, choose SOCKS5 when you need its additional protocol features, and check whether DNS lookups are sent through the proxy or resolved locally. An application that supports only HTTP proxies cannot use a SOCKS endpoint without an additional adapter.

Use loopback for a personal proxy

Bind the SOCKS listener to 127.0.0.1 or ::1. Binding it to a wildcard address can turn the VPS connection into an unintended open proxy for other devices that can reach your workstation. If another device must use it, restrict the listening interface and firewall source addresses, and understand that every permitted user can generate traffic through your VPS account.

Keep a tunnel running without a remote shell

The -N option tells SSH not to execute a remote command. It is appropriate when the session exists only to carry forwarding. The terminal remains attached to the SSH process, so closing it normally closes the tunnel.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a short-lived tunnel, keep the foreground command visible so failures are obvious. For a supervised service, use your operating system’s service manager or a carefully configured process monitor rather than hiding errors with ad-hoc backgrounding. If you do run a background session, verify that the listener exists and that reconnect behavior is intentional; an apparently running SSH process is not proof that the destination service is reachable.

Multiple forwarding options can be placed on one SSH command when the account policy permits them:

ssh -N 
  -L 127.0.0.1:15432:10.20.0.15:5432 
  -L 127.0.0.1:18080:127.0.0.1:8000 
  user@vps

Each listener is independent. A failure to connect through one destination does not necessarily mean the other forwarding rule is invalid.

Server-side controls that decide whether forwarding works

AllowTcpForwarding

The SSH server can allow all TCP forwarding, allow only local forwarding, allow only remote forwarding, or disable TCP forwarding. If a use case needs only one direction, selecting local or remote reduces the account’s capabilities compared with unrestricted forwarding. A setting of no blocks both directions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DisableForwarding

DisableForwarding disables forwarding features broadly for a connection. It can override otherwise permissive forwarding settings, so inspect it when every forwarding mode is rejected.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Key and account restrictions

Restrictions attached to the login key in authorized_keys can narrow forwarding even when the global server configuration allows it:

  • no-port-forwarding denies port forwarding for that key.
  • permitopen limits the host and port that a local forward may open.
  • permitlisten limits the address and port on which a remote forward may listen.

For a service account, combine the smallest necessary forwarding permission with a restricted account or forced command where appropriate. A credential that exists only to maintain one tunnel should not automatically receive an interactive shell and unrestricted access to arbitrary destinations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspect and change the effective configuration safely

Use the configuration-inspection tools installed with your OpenSSH release to determine the effective values, including settings from included drop-in files. Edit the relevant sshd_config file or drop-in, validate syntax with the release’s SSH daemon test mode, and then reload the service. Keep an existing administrative SSH session open while changing access policy so a syntax error or overly strict rule does not lock you out. The VPS provider’s firewall or security-group rules are separate from OpenSSH policy and must be checked independently.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Firewall and network considerations

A loopback-only local or remote listener does not require an inbound firewall opening for other hosts, because applications connect through the local machine. A remote forward bound to a VPS private or public interface may require an inbound rule in the VPS operating-system firewall, the provider’s security group, or both.

Forwarding does not bypass a destination service’s own network restrictions. For a local forward, the VPS must be able to resolve and reach the destination host and port. For a remote forward, your computer must be able to reach the destination. Test from the relevant side with the platform’s normal TCP tools, and confirm that the service is listening on the address you selected rather than only on an inaccessible interface.

Do not confuse an SSH listener port with the service’s original port. The listener can use any unused unprivileged port, while the destination can remain on its standard port. Privileged ports may require additional operating-system permission on the machine where the listener is created.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting by symptom

“administratively prohibited”

This message usually means a server-side forwarding policy or a key restriction rejected the request. Check AllowTcpForwarding, DisableForwarding, the key’s no-port-forwarding, permitopen and permitlisten options, and any account-specific configuration. If only one direction fails, compare the requested mode with a possible local-only or remote-only policy.

“bind: Address already in use”

The listener port is occupied on the side where the forward is created. For -L, inspect processes on your workstation; for -R, inspect processes on the VPS. Stop the conflicting service only if it is safe to do so, or choose another listener port.

The remote forward works on the VPS but not elsewhere

Test the listener first from the VPS itself. If that succeeds but another machine cannot connect, the usual causes are loopback binding or GatewayPorts no. Request an intentional bind address, set a server policy that permits it, and open only the required firewall path. Do not solve this by blindly binding to all interfaces.

The dynamic proxy appears to do nothing

Confirm that the application is configured for SOCKS at the exact loopback address and port used by -D. A program with no SOCKS support will ignore the listener. Also check whether the application sends DNS requests through SOCKS; local DNS resolution can make a connection appear to bypass the proxy even while TCP traffic is tunneled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The tunnel connects but the destination is unreachable

An established SSH session proves only that the client reached the VPS. The VPS-side destination in a local forward, or the client-side destination in a remote forward, can still be down, firewalled, bound to another address, or unavailable by name. Test the destination from the side that is supposed to open the connection and verify the host and port in the forwarding option.

A service is exposed unexpectedly

Inspect the listener address with the operating system’s socket-listing tool. Replace wildcard binds with 127.0.0.1 or ::1, remove unnecessary remote forwards, close stale SSH sessions, and review both SSH key restrictions and firewall rules. A tunnel that is no longer needed should be terminated rather than left connected indefinitely.

Security checklist for production and temporary tunnels

  • Use an explicit loopback bind for administrative dashboards, databases and development servers unless a wider audience is a documented requirement.
  • Grant only the forwarding direction needed: AllowTcpForwarding local for local-only use or remote for remote-only use.
  • Use key restrictions such as permitopen and permitlisten to constrain destinations and listener addresses.
  • Use a dedicated, restricted account for automation; add a forced command when the account does not need a shell.
  • Apply VPS firewall and provider security-group rules separately from SSH policy.
  • Keep an administrative session open while validating SSH configuration changes.
  • Choose listener ports that do not collide with existing services, and document which side owns each port.
  • Close tunnels when the task ends and monitor long-lived sessions for unexpected reconnects or destination failures.

Practical decision examples

You need a private VPS database on your laptop

Use -L. Bind a local high port to loopback, point the destination at the database address as seen from the VPS, and configure your database client for the local endpoint.

A VPS webhook process must call your laptop

Use -R. Keep the VPS listener on loopback unless the webhook process runs on another host; if it does, select a specific reachable bind address, obtain the required GatewayPorts permission, and protect the service.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

One browser needs to reach several destinations through the VPS

Use -D and configure that browser for SOCKS. A separate fixed -L rule would be needed for each destination and port, while dynamic forwarding lets the SOCKS-aware application select them per request.

You want to publish a local development site temporarily

Use -R, but remember that the default remote listener is VPS-local. Public or team access requires an intentional non-loopback bind, compatible GatewayPorts policy, firewall rules and application-level authentication. SSH encryption does not make an unauthenticated web service safe to publish.

What SSH port forwarding does not provide

Forwarding carries TCP streams described by OpenSSH’s forwarding options. It is not a general VPN, does not transparently route every application, and does not turn UDP-based protocols into TCP without another technology. A SOCKS tunnel still depends on application support, while a fixed local or remote forward handles only the destination rule you specify. If you need network-layer routing, broadcast behavior, or native UDP transport, use a technology designed for those requirements instead of extending an SSH command beyond its guarantees.

The Bottom Line

Use -L to bring a VPS-reachable service to your computer, -R to make a computer-side service reachable from the VPS, and -D for application-selected SOCKS destinations. Start with loopback binds and -N, then expand listener addresses or forwarding permissions only when the network path, firewall and account restrictions have been designed for that exposure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.