Would you like to learn how to test the TCP port connectivity using Python? In this tutorial, we are going to show you how to use Python to test the TCP connection to remote hosts.

• Ubuntu 20
• Ubuntu 19
• Ubuntu 18
• Python 3.8.5

Equipment list

Here you can find the list of equipment used to create this tutorial.

This link will also show the software list used to create this tutorial.

Related tutorial – Python

On this page, we offer quick access to a list of tutorials related to Python.

Tutorial Python – Test the TCP port connectivity

Test the connectivity to a TCP port using Python.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

Congratulations! You are able to test the TCP port connectivity using Python.

Tutorial Python – Test the TCP port connectivity using a script

Create a text file containing the IP list or hostnames.

Copy to Clipboard

Create a text file containing the desired TCP ports.

Copy to Clipboard

Test the connectivity to the TCP ports using a Python script.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

Congratulations! You are able to test the TCP port connectivity using a Python script.