Networking

How to Enable Telnet in Windows 11 and 10 and Test a Port

To enable telnet on Windows 11 or 10, open an elevated PowerShell window and run Enable-WindowsOptionalFeature -Online -FeatureName TelnetClient, or tick Telnet Client under Turn Windows features on or off. Then run telnet <host> <port> in a new Command Prompt to test whether a TCP port accepts connections.

Telnet is not installed by default. Microsoft's own documentation for the command says you must install the telnet client software before you can run it, so a fresh Windows install answers telnet with "'telnet' is not recognized as an internal or external command". The steps below fix that, and the second half shows what the client is actually good for today: checking whether a port is open.

Enable telnet from Windows Features

This is the graphical route. The archived Microsoft procedure for Windows 7 and Vista uses the same dialog, and it is still reachable on current Windows through Control Panel:

  1. Open Control Panel, then Programs.
  2. Under Programs and Features, click Turn Windows features on or off.
  3. Confirm the User Account Control prompt if it appears.
  4. In the Windows Features list, tick Telnet Client and click OK.

Windows installs the feature, and you can use it straight away. You need to be a member of the local Administrators group, because the feature install changes the system. Open a new Command Prompt or PowerShell window afterwards so the shell picks up the new telnet.exe.

Enable telnet from PowerShell

Open PowerShell as administrator (right-click Start, then choose the Terminal or PowerShell entry marked Admin) and run:

Enable-WindowsOptionalFeature -Online -FeatureName TelnetClient -NoRestart

-Online targets the running copy of Windows, -FeatureName names the feature, and -NoRestart stops the cmdlet from prompting for a restart if none is needed. The feature name comes from Microsoft's archived install page, which uses TelnetClient with the older pkgmgr tool. Feature names are not always identical across Windows releases, so if the cmdlet reports that the feature does not exist, list the names your system actually has:

Get-WindowsOptionalFeature -Online | Where-Object FeatureName -like "*telnet*"

Pass the name that command prints to -FeatureName. The same listing cmdlet is the one Microsoft's documentation points to for finding feature names.

On Windows 7 and Vista, Microsoft's archived page gives a one-line alternative from an elevated Command Prompt: pkgmgr /iu:"TelnetClient". Newer Windows versions are better served by the PowerShell command above.

Check that telnet works

Open a new Command Prompt and run the command with no arguments:

telnet

If the client is installed, you land at a Microsoft telnet> prompt, as the reference page describes. Type ? there to list the client's own commands, or run telnet /? from the normal prompt to print the syntax. If you still see "not recognized", the feature did not install or the window was opened before the install finished.

How to test a port with telnet

The syntax from Microsoft's reference is telnet [<host> [<port>]]. The host can be a name or an IP address, and if you leave out the port, the client uses TCP port 23, the default registered for Telnet in RFC 854. To test any other service, give the port explicitly:

telnet mail.example.com 25

Two outcomes matter:

  • The screen clears or shows a banner. The TCP connection succeeded, so something is listening on that port and no firewall dropped your packets. A mail server on port 25, for example, typically prints a greeting line.
  • An error appears and you return to the prompt. The connection failed. The usual message is Could not open connection to the host, on port 25: Connect failed (example output; the exact wording can differ between Windows versions). That means the port is closed, the service is not running, a firewall is blocking it, or the host name did not resolve.

A blank window with a blinking cursor is a success, not a hang: the connection is open and the server is waiting for you to speak first. Many services, including HTTP, wait for the client to send a request. Close the window, or use the client's escape character to reach the Microsoft telnet> prompt. The /e option lets you choose that escape character when you start the client.

Other telnet options worth knowing

Microsoft documents a few switches you can add before the host name:

OptionWhat it does
/f <filename>Logs the session to a local file, for example telnet /f telnetlog.txt telnet.microsoft.com 44
/e <escapechar>Sets the escape character used to reach the telnet client prompt
/t {vt100 | vt52 | ansi | vtnt}Sets the terminal type
/l <username>Logs on with that user name on the remote computer

Test a port without telnet: Test-NetConnection

If all you want is a yes or no answer, PowerShell already has a built-in tool and nothing to install:

Test-NetConnection -ComputerName mail.example.com -Port 25

The cmdlet opens a TCP connection to that port and reports the result. Look for TcpTestSucceeded, which is True when the connection was established. Microsoft's reference shows this property in its TCP example with -InformationLevel "Detailed". For a bare True or False that suits scripts, add -InformationLevel Quiet:

Test-NetConnection -ComputerName mail.example.com -Port 25 -InformationLevel Quiet

For a handful of common services you can use a name instead of a number. The -CommonTCPPort parameter accepts HTTP, RDP, SMB and WINRM:

Test-NetConnection -ComputerName server01 -CommonTCPPort RDP

That last check is handy when Remote Desktop will not connect: if the RDP test fails, the problem is the network path or firewall rather than your credentials. Our guide to enabling Remote Desktop on Windows 11 and 10 covers the setting on the target machine.

Without -Port, the cmdlet runs a ping test instead, and its output includes PingSucceeded. A host can fail a ping and still accept connections on a port, because many firewalls block ICMP, so test the port itself.

Telnet versus Test-NetConnection

telnetTest-NetConnection
Installed by defaultNo, optional featureYes, in the NetTCPIP module
Needs administrator rightsTo install itNo
ResultVisual: banner, blank screen or errorText with TcpTestSucceeded, or a Boolean with Quiet
Lets you type to the serviceYesNo
Easy to scriptAwkwardYes

Use telnet when you want to type a few lines to a text-based service and see what it says back. Use Test-NetConnection for everything else.

Security: do not log in over telnet

RFC 854 describes Telnet as a general, bi-directional, eight-bit byte oriented communications facility running over a TCP connection, and it specifies no encryption. Anything you type, including a password, travels as plain text. That is why the client is switched off by default and why remote administration moved to SSH. Treat the Telnet Client as a diagnostic tool: connect, see whether the port answers, disconnect. Do not enter credentials into a telnet session on a network you do not fully control.

The Telnet Server is a separate component and you do not need it for any of the steps here. Installing the client does not open any port on your own machine.

If the port test fails

  • Check the name first. If a host name fails but its IP address works, the problem is DNS, not the port.
  • Check the service. On the target machine, confirm something is listening. If you run the service yourself and see an address-in-use error instead, see how to fix "port already in use".
  • Check the firewall. A rule on the target, on your router, or on a cloud security group can drop the connection. Telnet then waits and finally reports a failure instead of an immediate refusal.
  • Check the port number. A typo in the port gives the same error as a closed service.

To remove the client later, clear the Telnet Client tick in Turn Windows features on or off, or use Disable-WindowsOptionalFeature, the counterpart of the enable cmdlet that Microsoft lists under its related links.

Frequently asked questions

Why does Windows say 'telnet' is not recognized as a command?
The Telnet Client is an optional Windows feature and is not installed by default. Microsoft's documentation says you must install the telnet client software before the telnet command can run. Turn on Telnet Client in Windows Features, or enable it from an elevated PowerShell window, then open a new Command Prompt.
Is it safe to use telnet?
Installing the client is low risk, but sending anything sensitive over telnet is not. RFC 854 defines no encryption, so everything you type, including passwords, crosses the network as plain text. Use telnet only to test whether a port answers, and use SSH for remote logins.
Can I test a port without installing telnet?
Yes. In PowerShell, Test-NetConnection -ComputerName <host> -Port <port> opens a TCP connection and reports TcpTestSucceeded as True or False. It ships with Windows and needs no installation.
Does telnet work for UDP ports?
No. Telnet opens TCP connections, so it can only tell you about TCP ports. A closed result says nothing about UDP services such as DNS on UDP 53.

Sources