The tnc command is the quickest built-in PowerShell way to check whether a remote TCP port accepts connections from your Windows computer. You can use it for RDP port 3389, HTTPS port 443, SSH, a custom application port, or any other TCP service without installing a port-checking app.
tnc in one line
tnc is the short PowerShell alias for Test-NetConnection. When you include -Port, PowerShell attempts a TCP connection to the target hostname or IP address and reports the result in TcpTestSucceeded.
The basic pattern is:
tnc -ComputerName <hostname-or-ip> -Port <port>
For example, to test a server’s HTTPS port:
tnc -ComputerName example.com -Port 443
Microsoft documents Test-NetConnection as a diagnostic cmdlet for ping tests, TCP tests, route tracing, and route-selection diagnostics. The -Port parameter specifically tests TCP connectivity to the remote computer, while -InformationLevel Quiet returns a simple Boolean result. Read the Microsoft reference for Test-NetConnection.
What you need before testing
You need three pieces of information:
- The destination hostname or IP address, such as
rdp.example.comor198.51.100.25. - The TCP port, such as
3389for a normal RDP listener or443for HTTPS. - A reason to expect a service there. A failed test does not tell you whether the service is stopped, the port is wrong, DNS is incorrect, or a firewall is filtering traffic.
Run the command from the same type of network that the real client will use. A test from inside a private network can succeed while an internet test fails because perimeter rules and routing differ. Only test systems you own or administer.
Step 1: Test a standard port
Start with the fully named form so the purpose of each value is obvious.
tnc -ComputerName 203.0.113.25 -Port 3389
Why: this checks whether your current computer can complete a TCP connection to port 3389 on the target.
Success looks like TcpTestSucceeded : True. If you are checking a Windows RDP server, that means the TCP path to the RDP listener is working from your test machine. It does not yet prove that the username, password, NLA settings, or the complete graphical RDP session will work.
You can use a hostname instead:
tnc -ComputerName rdp.example.com -Port 3389
If the hostname test fails, repeat it with the server’s IP address. A successful IP test and a failed hostname test usually points to DNS or name-resolution trouble rather than a closed service port.
Step 2: Test RDP and custom ports
For RDP’s default TCP port, PowerShell also supports the named common-port option:
tnc -ComputerName 203.0.113.25 -CommonTCPPort RDP
The explicit -Port 3389 form is easier to audit and is the better choice when a server uses a non-default RDP port. For example, if RDP listens on 3390:
tnc -ComputerName 203.0.113.25 -Port 3390
The same pattern works for web applications, APIs, databases, and SSH:
tnc -ComputerName app.example.com -Port 8443
tnc -ComputerName 203.0.113.25 -Port 22
tnc -ComputerName db.example.com -Port 5432
The port number is not a service guarantee. A TCP connection to 8443 tells you that something accepted the connection; it does not confirm that the application speaks HTTPS or that it is healthy after the handshake. Use an application-level request when you need to verify the protocol itself.
For RDP troubleshooting, first check the port the server is actually configured to use. If you connect with a custom port, the RDP client should use the form hostname:port or ip-address:port. See how to access RDP with a custom port for the connection-side details.
Step 3: Read the output correctly
A normal detailed result can include fields similar to these:
ComputerName : 203.0.113.25
RemoteAddress : 203.0.113.25
RemotePort : 3389
InterfaceAlias : Wi-Fi
SourceAddress : 192.0.2.10
TcpTestSucceeded : True
The important fields are:
| Field | Meaning |
|---|---|
ComputerName | The hostname or address you supplied. |
RemoteAddress | The address selected after DNS resolution. |
RemotePort | The TCP port tested. |
InterfaceAlias | The local network interface used for the route. |
SourceAddress | The local address used for the connection. |
PingSucceeded | Whether an ICMP echo reply was received, when a ping was attempted. |
TcpTestSucceeded | Whether the TCP connection to the specified port succeeded. |
Treat TcpTestSucceeded as the answer to the port question. PingSucceeded : False does not automatically mean the TCP port is closed; many servers and firewalls block ICMP while allowing TCP. Conversely, a successful ping only proves that the host answered ICMP, not that your application port is listening.
For scripts, request only the Boolean result:
tnc -ComputerName app.example.com -Port 443 -InformationLevel Quiet
Expected output:
True
You can store the result and branch on it:
$portOpen = tnc -ComputerName app.example.com -Port 443 -InformationLevel Quiet
if ($portOpen) {
'TCP port is reachable'
} else {
'TCP port is not reachable'
}
Step 4: Use Linux and macOS equivalents
On Linux and macOS, nc (netcat) is the simple equivalent for one TCP port. The exact flags can vary between netcat packages, but this common form works on many systems:
nc -vz -w 5 example.com 443
Here, -v asks for verbose output, -z checks for a listening service without sending application data, and -w 5 sets a five-second timeout on implementations that support it. On macOS, start with the shorter command if the installed version does not accept -w:
nc -vz example.com 443
A success message normally includes succeeded or open. A refusal usually means the host was reachable but no service accepted that port. A timeout often indicates filtering, a routing problem, or a host that did not respond. The OpenBSD nc manual documents -z for scanning without sending data and -w for connection timeouts.
For a more detailed scan, use Nmap if it is installed:
nmap -Pn -p 3389 203.0.113.25
-p limits the scan to the port you specify. -Pn skips host discovery, which is useful when ICMP echo requests are blocked. Nmap may report open, closed, or filtered: open means an application is accepting connections, closed means the host is reachable but no application is listening, and filtered means a filter prevents Nmap from determining the state. The Nmap port-scanning reference explains why results can differ depending on where the scan originates.
These commands test TCP. They do not prove that a UDP service is available. Test-NetConnection -Port is also a TCP test, so use a protocol-specific diagnostic when an application depends on UDP.
Step 5: Check the server when the port is closed
Run the next checks on the server itself, preferably through a console or another management path if RDP is unavailable.
First, confirm that a process is listening on the expected port:
Get-NetTCPConnection -LocalPort 3389 -State Listen
Success is a returned connection object showing a listening local endpoint. If there is no result, check the service or application configuration. For the Windows RDP service, you can check the service state with:
Get-Service -Name TermService
Next, inspect the relevant firewall rules without turning the firewall off:
Get-NetFirewallRule -DisplayGroup "Remote Desktop" |
Format-Table DisplayName, Enabled, Profile, Direction, Action
For a custom application port, inspect the rule created for that application or port and confirm that it applies to the active network profile. If a rule needs changing, restrict it to the required protocol, port, profile, and source networks. Allowing a port in Windows Server 2019 Firewall covers the Windows-side rule workflow.
Then test in layers:
- Test
localhostand the port on the server to confirm a local listener. - Test the server’s private or public IP from a second machine.
- Test the hostname to separate DNS problems from network problems.
If localhost succeeds but a remote test fails, investigate Windows Firewall, a cloud security rule, a router, or a provider-side network policy. If the IP works but the hostname fails, fix DNS or use the correct address. If every test fails, verify the port number and application listener before changing firewall rules.
Verify before you call the problem solved
Repeat the test from the actual client network after each change:
tnc -ComputerName your-server.example.com -Port 3389 -InformationLevel Detailed
Confirm the resolved RemoteAddress is the intended server and that TcpTestSucceeded is True. Then try the real application. A successful TCP check proves reachability to the port; it does not replace an application login or protocol test.
FAQ
What is the tnc command in PowerShell?
tnc is the short alias for Test-NetConnection. Add -Port to test a remote TCP port, for example tnc example.com -Port 443.
How do I check if RDP port 3389 is open?
Run tnc -ComputerName <server-ip> -Port 3389 from the client computer. Read TcpTestSucceeded; True means the TCP connection reached the target port from that client, while False means you need to investigate the path, listener, or filtering.
Why does tnc show ping succeeded but TCP failed?
Ping and TCP use different protocols and can be treated differently by firewalls. A host can answer ICMP while blocking port 3389, or it can allow TCP while blocking ping, so use TcpTestSucceeded for the port result.
Can tnc test UDP ports?
No. The -Port parameter tests TCP. Use an application-specific UDP check or a tool designed for the service when UDP matters.
Is a closed port always a firewall problem?
No. A stopped service, wrong port number, DNS error, route problem, or firewall can all produce a failed connection. Check for a local listener first, then test the firewall and network path from the client side.
DONE check-if-port-is-open-tnc words=1445