Port forwarding VPS setup is one of the first practical skills you need when you move from shared hosting to a server you manage yourself. A port has to be allowed through every firewall layer, a service has to be listening behind it, and the complete chain has to be verifiable from the outside. Miss any one of those three layers and the connection fails — usually with an unhelpful timeout rather than a clear error message.
This tutorial walks through the full workflow on a Windows VPS: opening a port in Windows Defender Firewall for RDP, confirming something is listening behind it, and testing from an external machine. It also covers Linux firewalls (UFW, iptables), provider firewalls at Hetzner, Contabo, DigitalOcean, and AWS Lightsail, changing the RDP port, and a troubleshooting table for closed ports. Every command is a standard configuration option documented by its vendor, so you can verify each step against a primary source.
Last updated: October 27, 2026 · Reading time: ~12 minutes · Includes video walkthrough
Video Tutorial: How to Open Port Forwarding on a VPS (RDP)
The video demonstrates the core sequence on a Windows VPS: creating an inbound rule in Windows Defender Firewall, listening on the port, and checking the result with an external port checker. The article follows the same sequence and adds what a short video cannot cover — provider firewalls, Linux commands, changing the RDP port, and systematic troubleshooting.
What Is Port Forwarding on a VPS — and When Do You Actually Need It?
Port forwarding is a networking technique that redirects incoming traffic from one port on a gateway — a router or firewall — to a different port or host behind that gateway. It is the standard way to expose a service on a private network: traffic arriving at the gateway’s public address on port 443 can be forwarded to an internal machine on port 3389. The concept is a special case of Network Address Translation, covered in general references such as Wikipedia’s port forwarding article.
On a VPS the term needs a small translation, because most virtual private servers do not sit behind a home-style router: a typical VPS binds its own public IPv4 address directly to the network interface. In that common case, port forwarding on a VPS reduces to two jobs — allowing the port through the provider firewall and the operating-system firewall, and making sure the service binds to the right interface. True DNAT-style forwarding, where the destination port is rewritten, only becomes necessary when external port 443 must reach internal port 3389, or when traffic routes on to a second, internal machine.
Both situations appear constantly in remote-access work: RDP listens on TCP 3389 and that port must be reachable before any remote desktop session can open, and the same three-layer check — provider firewall, host firewall, listening service — decides whether any self-hosted service is reachable. The workflow below covers the layers in the order a packet actually meets them.
Prerequisites for VPS Port Forwarding
Once your VPS listener is reachable, the next step in a typical engagement workflow is validating that the payload you intend to deliver still behaves as expected against current detection stacks — our best crypter in 2025 guide walks through the 4-step testing protocol we use to confirm a build is deployment-ready before it ever touches the listener you just opened.
Before you start, confirm you have the following:
- A VPS with a static public IP address, confirmed in your provider’s control panel — a changed IP invalidates every check that follows.
- Administrative access to the VPS — administrator rights over RDP on Windows, or root/sudo on Linux; firewall rules are system-wide changes.
- The port and protocol you want to open — for RDP, TCP 3389 by default. Windows Defender Firewall treats TCP and UDP as separate rules, so decide both in advance.
- Access to your provider’s control panel, in case a cloud firewall sits in front of your instance — the layer most tutorials forget to check.
- A way to test from outside the VPS — a second machine or a browser-based port checker; testing from the server itself cannot prove internet reachability.
- A snapshot or backup taken before you begin — firewall and registry changes are quick to make and quick to mis-make, and a rollback point turns a bad rule into a two-minute fix.
If you are still shopping for a VPS with port forwarding already enabled out of the box — meaning a provider whose cloud firewall exposes inbound rules in the control panel and whose default images leave iptables and Windows Defender Firewall in a predictable state — Hetzner, Contabo, DigitalOcean, and AWS Lightsail all qualify. The rest of this guide assumes you already have one provisioned and SSH or RDP access working.
How to Listen to a Port on Your VPS
A port being “open” in a firewall is not the same thing as a port being usable. For a device to receive incoming traffic on a specific port, an application or service has to be running and bound to that port, actively waiting for connections — that is what listening means. A forwarded port that no process listens on will still reject connections, which is why an open firewall rule alone never makes a service reachable.
On Windows, check what is listening with the built-in tools — netstat is documented by Microsoft:
netstat -ano | findstr :3389The output shows the local address — 0.0.0.0:3389 for all IPv4 interfaces, [::]:3389 for IPv6 — then LISTENING and the owning process ID. The bind address matters: 0.0.0.0 accepts connections on every interface, including the public one; 127.0.0.1 binds to loopback only and will never accept internet traffic, no matter how many firewall rules you create. Map the PID to a service with tasklist /svc /fi "PID eq — for RDP it should be the Remote Desktop Services service (TermService).
ss -tlnpLook for your port in the LISTEN column and confirm the bind address is 0.0.0.0 or * rather than 127.0.0.1. Then test locally before remotely: Test-NetConnection 127.0.0.1 -Port 3389 on Windows or nc -zv 127.0.0.1 on Linux. A local success paired with a remote failure means the service is fine and the problem is a firewall — the distinction the troubleshooting table is built around.
How to Open a Forwarding Port and Listen to It (Step by Step)
Step 1 — Decide the port and protocol. For a standard RDP setup that is TCP 3389; if you plan to move RDP off the default port, decide the number now (see the dedicated section below) so you only write rules once. Windows Firewall rules are per-protocol, so note the TCP and UDP decisions separately.
Step 2 — Open the port in Windows Defender Firewall.
- Open Windows Defender Firewall — Win + R, type firewall.cpl, press Enter — then choose Advanced settings.
- Select Inbound Rules, then click New Rule…
- Choose Port and click Next.
- Select TCP, enter your port number, and click Next. If your service uses both protocols, open the port in both — TCP and UDP rules are created separately.
- Leave Allow the connection selected, choose the network profiles the rule applies to, and click Next.
- Name the rule so you can recognize it later — write the protocol into the name, for example RDP-TCP-3389, so you can tell TCP and UDP rules apart at a glance.
- Repeat the same steps for UDP if your service needs it.
The PowerShell equivalent, per Microsoft’s listening-port documentation, is one command per protocol:
New-NetFirewallRule -DisplayName 'RDP-TCP-In' -Profile Public -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3389Step 3 — Check the port from the outside. Use an external port checker (the original video uses Canyouseeme) or a second machine with Test-NetConnection . A failure right after opening the firewall rule is expected — it is the exact failure the video demonstrates. An open firewall port is a road with no building at the end of it: until a service listens, the outside world connects to nothing. The next step fixes that.
Step 4 — Make the service listen on the port. On Windows, RDP listens automatically once Remote Desktop is enabled — verify with the netstat command above. For any other service, start it and confirm it binds to 0.0.0.0 rather than 127.0.0.1; loopback binding is the single most common cause of a "closed" port with perfect firewall rules. For a quick reachability test, a temporary listener such as nc -l 0.0.0.0 3389 on Linux (Ctrl+C to stop) is enough.
Step 5 — (Optional) Forward one external port to a different internal port. This is port forwarding in the strict NAT sense, needed only when the external and internal port numbers must differ. On Windows the built-in mechanism is netsh interface portproxy; on Linux, an iptables PREROUTING rule (netfilter documentation):
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=443 connectaddress=127.0.0.1 connectport=3389iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:3389Both commands make external port 443 deliver traffic to local port 3389. Adjust the addresses and ports to your layout; the host firewall still has to allow the internal port as well.
Step 6 — Verify the full chain. Re-run the external check from Step 3. A port that answers now confirms all three layers are aligned: provider firewall, host firewall, listening service. If it still fails, jump to the troubleshooting table — the specific failure mode (refused versus timeout) tells you which layer to inspect first.
Port Forwarding for RDP: Changing the Default Listening Port
Remote Desktop listens on TCP 3389 by default, and every port scanner on the internet knows it. Moving RDP to a non-standard port reduces log noise from indiscriminate scans — a documented configuration option in Microsoft’s guide to changing the listening port — but it deserves honest framing up front: a determined attacker scans all 65,535 ports, so a non-standard port cuts automated noise, not targeted attacks. The controls that actually harden RDP follow the how-to.
RDP port forwarding is the single most common reason readers land on this guide — Remote Desktop is the first service most VPS operators expose, and the default 3389 listener is the first thing internet-wide scanners hammer. The rest of this section walks through changing that default and the firewall rules that have to move with it.
The listening port is set by the PortNumber registry value under HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp. Microsoft's PowerShell sequence — check the current value, set the new one, create the matching firewall rule — is:
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name 'PortNumber'
$portValue = '3390'
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name 'PortNumber' -Value $portValue
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile Public -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portValueAfter the change, restart the Remote Desktop Services service or reboot, and connect with the port appended to the address — 203.0.113.10:3390 in the Remote Desktop Connection client. Three follow-ups matter: create the firewall rule for the new port before you disconnect your current session, or you lock yourself out; note the change, because every future connection and monitoring check must specify the new port; and update any provider-level firewall that still allows only 3389.
What actually protects RDP is the authentication layer. Microsoft’s Remote Desktop Services documentation covers Network Level Authentication (NLA), which authenticates the user before a full session is established and is required by default on current Windows Server versions. Windows Server 2025 is the current Long-Term Servicing Channel release — Windows Server 2022 left mainstream support in October 2026 — so new deployments should target it. Strong unique credentials, NLA left enabled, source-IP restrictions where practical, and prompt patching are the controls that matter; the port number is a footnote.
VPS Firewall Configuration: Opening Ports on Popular Providers
Before a packet reaches Windows Defender Firewall or UFW, it can be stopped by a firewall you did not configure — the provider’s. A port that is open in the operating system but unreachable from the internet is usually blocked one layer up. The evaluation order never changes: provider cloud firewall, then host firewall, then listening service.
- Hetzner — the Cloud Console includes a managed Cloud Firewall you attach to a server; inbound rules define port, protocol, and source CIDR. With none attached, the instance is exposed directly to the host firewall.
- Contabo — instances are managed through the customer panel, which includes a firewall service with per-instance rules. Check whether it is enabled before blaming the operating system.
- DigitalOcean — Droplets can sit behind a cloud firewall; on the Droplet itself, the standard host firewall is UFW, covered in DigitalOcean’s UFW tutorial.
- AWS Lightsail — the console’s Networking tab holds the IPv4 firewall rules; only listed ports reach the instance.
Learning how to open ports on a VPS follows the same layer-by-layer model regardless of provider: cloud firewall first, host firewall second, listening service third. The provider-specific notes below cover the four hosts we see most often in our community’s C2 and remote-access setups.
On the host itself, the Linux commands for the same job are short. UFW:
ufw allow 3389/tcp
ufw status verboseSource-restricted — the better shape for admin ports, where only one office or VPN subnet should connect:
ufw allow from 203.0.113.0/24 to any port 3389 proto tcpThe raw iptables equivalent is iptables -A INPUT -p tcp --dport 3389 -j ACCEPT (netfilter documentation). On Windows, one gotcha deserves its own paragraph: inbound rules are scoped to network profiles — Domain, Private, Public — and a VPS interface often registers as Public. A rule scoped to Private only silently blocks the traffic you meant to allow while looking perfectly correct in the rule list. When a rule appears right but does not pass traffic, check the profile first.
One more internet-path case: if the hostname is proxied by Cloudflare, only HTTP and HTTPS ports traverse the proxy — arbitrary TCP ports such as 3389 do not, per Cloudflare’s network ports reference. For non-HTTP services, connect by the server’s direct address or a DNS-only record.
Does Malware Use Port Forwarding? A Defensive View
Yes — and the concept is worth understanding even if you never touch the offensive side. Malware uses port forwarding, tunneling, and reverse connections to maintain remote access and bypass security measures. A pathway from a compromised device lets an intruder reach a backdoor, relay traffic through the machine as a proxy, or preserve access across reboots. Remote access trojans abusing RDP and VNC likewise depend on a reachable listener or an outbound tunnel.
One refinement matters for defenders: classic port forwarding favors the attacker only when inbound connections are possible. Because most networks allow outbound traffic freely, modern intrusions more often use reverse connections — the compromised machine connects outward to a controller, so no inbound forwarding is needed at all. “Which ports are listening?” is therefore only half the audit question; the other half is “which unexpected outbound connections exist?”.
For administrators, the practical checks are unspectacular and effective. Inventory listening ports on a schedule (netstat -ano on Windows, ss -tlnp on Linux) and investigate entries you cannot map to a known service. Treat new firewall rules — especially rules opening non-standard ports — as security events worth an explanation. Alert on unfamiliar processes holding long-lived outbound connections. Where the environment allows, egress filtering (allow-listing the destinations a server may contact) removes most tunnel-based footholds by default.
For operators evaluating remote access tooling as part of an authorized engagement, the same listener-and-firewall workflow applies — see our guide to choosing a RAT for use with a crypter for the connection-model context that makes port forwarding a prerequisite rather than an afterthought.
A related operational reality for anyone testing security tooling in authorized environments: legitimate administration and pen-testing utilities that open listeners or tunnels are frequently flagged by antivirus heuristics — a known false-positive class. Our crypter testing protocol describes a four-step AV false-positive check, and our RAT overview covers what remote administration tools require from network configuration in lab contexts. This page deliberately stays at the networking-configuration level.
Troubleshooting Common Port Forwarding Issues
The original tutorial kept a short bullet list of fixes. The table below maps each visible symptom to its most likely layer, so you can debug in order of probability instead of guessing. | Symptom | Most likely cause | Fix |
|—|—|—|
| Connection refused instantly | Host reachable, nothing listening on the port | Start the service; check the bind address (0.0.0.0, not 127.0.0.1) |
| Connection times out | Traffic dropped by a firewall | Check the provider cloud firewall, then host firewall rules and network profile |
| Works via localhost, fails remotely | Service bound to loopback only, or host firewall blocks external sources | Rebind the service to 0.0.0.0; verify the inbound rule covers the Public profile |
| RDP fails after changing the port | Firewall rule missing for the new port, or client omits the :port suffix | Add rules for the new port; connect as ip:port |
| Authentication error before the desktop appears | NLA/CredSSP negotiation failure, often an outdated client | Update the RDP client and server; keep NLA enabled (Microsoft RDP troubleshooting) |
| Port works, then fails intermittently | Brute-force protection banning your IP, or a changed client IP | Restrict the source IP in the provider firewall; review fail2ban-style tools |
| Works from one network, fails from another | Egress filtering on the client side (corporate or ISP) | Test from an independent network or a browser-based port checker |
| DNS name resolves but the port is closed | Hostname points to a proxy that does not forward that port | Bypass the proxy for non-HTTP ports (Cloudflare network ports) |
Two habits from the original tutorial still earn their place. Restart the VPS — or at least reload the firewall services — after configuration changes, so stateful rules re-initialize cleanly. And re-check each rule for typos: a rule for port 3399 instead of 3389 stays invisible until you diff it against the service. Where the original suggested temporarily disabling third-party firewalls to isolate a conflict, the safer equivalent is widening a rule for a few minutes of testing and narrowing it again, so the server is never fully unprotected on a public IP.
If your VPS sits behind Cloudflare’s proxy (orange-cloud DNS), remember that Cloudflare only proxies HTTP/HTTPS on a fixed list of ports — non-HTTP traffic on custom ports will time out unless you grey-cloud the DNS record or use Cloudflare Spectrum. See Cloudflare’s documentation on supported proxy ports for the current list. We recommend reading our crypter connection troubleshooting walkthrough
FAQ: Port Forwarding VPS
What is port forwarding on a VPS?
Port forwarding on a VPS means making a specific port reachable from the internet. Because most VPS instances bind a public IP directly to the server, it usually means two steps rather than a router rule: allow the port through the provider firewall and the operating-system firewall, and run a service that listens on it. NAT-style forwarding — rewriting an external port to a different internal one with netsh portproxy or iptables DNAT — only applies when the two port numbers must differ.
How do I open a port on my VPS?
Work through the layers a packet meets, in order. First the provider’s cloud firewall — Hetzner, Contabo, DigitalOcean, and Lightsail all offer one — with an inbound rule for your port and protocol. Then the operating-system firewall: an inbound rule in Windows Defender Firewall, or ufw allow 3389/tcp on Linux. Finally, start the service so something listens, and verify from an external machine.
What port does RDP use, and can I change it?
Remote Desktop listens on TCP port 3389 by default. You can change it by setting the PortNumber registry value under HKLMSYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp, adding a firewall rule for the new port, and connecting as address:port; Microsoft documents the full procedure. Changing the port reduces scanner noise — it is not a substitute for NLA and strong credentials.
How can I check whether a port is open on my VPS?
Run two checks. On the VPS, netstat -ano | findstr :3389 on Windows or ss -tlnp on Linux confirms a service is listening and shows the bind address. From outside — a second machine with Test-NetConnection <IP> -Port <port> or a browser-based port checker — confirms reachability through every firewall layer. A port can pass locally and fail remotely; that combination means the problem is a firewall, not the service.
Is port forwarding on a VPS safe?
It is as safe as the service you expose. Every open port extends your attack surface to the whole internet, so the controls that matter live on the service: NLA for RDP, strong unique passwords or certificate-based login, source-IP restrictions where practical, prompt patching, and closing unused ports. Avoid disabling firewalls to make things work — widen a rule briefly for testing instead.
Does malware use port forwarding?
Yes. Intrusions use tunneling and forwarding to maintain access, relay traffic, or bypass security controls, and remote access trojans depend on reachable listeners or outbound connections. The defensive counterpart is monitoring: unexpected listeners, new firewall rules, and long-lived outbound connections to unfamiliar destinations are the standard audit signals. Modern malware favors outbound reverse connections, so egress filtering matters as much as inbound rules.
What is the difference between port forwarding and NAT?
NAT rewrites addresses so many hosts share one public IP; port forwarding is a specific NAT rule mapping one public port to one internal host and port. On a VPS with its own public address you typically do not need NAT at all — the practical work is firewall rules plus a listening service. The netsh portproxy and iptables DNAT examples above are the VPS-scale equivalent of router port forwarding.
Why is my forwarded port still closed?
The three most frequent causes, in order: nothing is listening on the port, or the service is bound to 127.0.0.1 instead of 0.0.0.0; a host firewall rule is missing or scoped to the wrong network profile; or the provider’s cloud firewall is blocking the port. Distinguish refusal from timeout — an instant refusal means the host answered but no listener exists; a timeout means a firewall silently dropped the packet. That distinction halves your debugging time.
About This Guide and Its Sources
Editorial note. Maintained by the Data Encoder documentation team. It presents no first-hand lab benchmarks or test results: stated behavior and configuration rest on the vendor documentation below, and the embedded video demonstrates the original workflow. Claims without a primary source are framed as general practice, not measured fact. Last verified: October 27, 2026.
Primary sources:
- Microsoft Learn — Remote Desktop Services, changing the RDP listening port, RDP troubleshooting, netstat reference
- Hetzner — Cloud Firewall
- Contabo — Firewall
- DigitalOcean — Cloud Firewalls and UFW tutorial
- AWS Lightsail — instance firewall rules
- Cloudflare — network ports supported by the proxy
- netfilter — iptables documentation
