How to use the command speedtest-cli (with examples) (2024)

Speedtest-cli is a command-line tool used to test internet bandwidth by connecting to speedtest.net servers. It provides precise details about download and upload speeds, latency, and server response times. The tool is highly versatile and offers various options to customize the test.

Use case 1: Run a speed test

Code:

speedtest-cli

Motivation: Running a basic speed test allows users to quickly assess their internet connection’s performance. This information is invaluable when troubleshooting network issues or comparing different service providers.

Explanation: The command speedtest-cli initiates the speed test. It connects to the closest available speedtest.net server and measures the download and upload speeds, as well as latency.

Example Output:

Retrieving speedtest.net configuration...Testing from ISP (IP address: x.x.x.x)...Retrieving speedtest.net server list...Selecting best server based on latency...Hosted by <Server Provider> [X.XX km]: 47.34 msTesting download speed........................................Download: 50.14 MbpsTesting upload speed..................................................Upload: 25.20 Mbps

Use case 2: Run a speed test and display values in bytes, instead of bits

Code:

speedtest-cli --bytes

Motivation: By default, speedtest-cli provides download and upload speeds in bits per second (Mbps). However, displaying values in bytes per second (MB/s) may be more familiar to users or better align with their requirements.

Explanation: The --bytes option changes the display units from bits to bytes. This modification provides speed test results in a more commonly recognized format.

Example Output:

Retrieving speedtest.net configuration...Testing from ISP (IP address: x.x.x.x)...Retrieving speedtest.net server list...Selecting best server based on latency...Hosted by <Server Provider> [X.XX km]: 47.34 msTesting download speed........................................Download: 6.27 MB/sTesting upload speed..................................................Upload: 3.15 MB/s

Use case 3: Run a speed test using HTTPS, instead of HTTP

Code:

speedtest-cli --secure

Motivation: Many users prefer the extra security provided by HTTPS, especially when transmitting sensitive data. Running the speed test over HTTPS ensures that the connection is encrypted and protected from potential eavesdroppers.

Explanation: The --secure option instructs speedtest-cli to use HTTPS for the speed test connection. This ensures the data transfer is encrypted.

Example Output:

Retrieving speedtest.net configuration...Testing from ISP (IP address: x.x.x.x)...Retrieving speedtest.net server list...Selecting best server based on latency...Hosted by <Server Provider> [X.XX km]: 47.34 msTesting download speed........................................Download: 50.14 MbpsTesting upload speed..................................................Upload: 25.20 Mbps

Use case 4: Run a speed test without performing download tests

Code:

speedtest-cli --no-download

Motivation: In certain circ*mstances, users may only need information about their upload speed or want to exclude download tests for faster results. This use case allows users to focus on a specific aspect of their internet connection speed.

Explanation: The --no-download option skips the download speed test and only performs the upload test and latency measurement.

Example Output:

Retrieving speedtest.net configuration...Testing from ISP (IP address: x.x.x.x)...Retrieving speedtest.net server list...Selecting best server based on latency...Hosted by <Server Provider> [X.XX km]: 47.34 msTesting upload speed..................................................Upload: 25.20 Mbps

Use case 5: Run a speed test and generate an image of the results

Code:

speedtest-cli --share

Motivation: Generating an image of the speed test results can facilitate sharing the information with others, such as network administrators or internet service providers. It provides a visual representation of the test outcome for easier analysis or communication.

Explanation: The --share option generates a unique URL that displays the speed test results as an image. The URL can be shared with others to provide access to the image.

Example Output:

Retrieving speedtest.net configuration...Testing from ISP (IP address: x.x.x.x)...Retrieving speedtest.net server list...Selecting best server based on latency...Hosted by <Server Provider> [X.XX km]: 47.34 msTesting download speed........................................Download: 50.14 MbpsTesting upload speed..................................................Upload: 25.20 MbpsShare results: <https://www.speedtest.net/result/image/xxxxxxxxxxx.png>

Use case 6: List all speedtest.net servers, sorted by distance

Code:

speedtest-cli --list

Motivation: Accessing a list of speedtest.net servers can be useful to see the existing options and determine the most suitable ones for a particular location. By sorting the servers by distance, users can identify the closest servers, usually resulting in more accurate test results.

Explanation: The --list option retrieves and lists all the speedtest.net servers. The servers are then sorted by distance, with the closest ones appearing first.

Example Output:

Retrieving speedtest.net configuration...1) <Server Name 1> Server ID: xxxxxxx Distance: X.XX km2) <Server Name 2> Server ID: xxxxxxx Distance: X.XX km...

Use case 7: Run a speed test to a specific speedtest.net server

Code:

speedtest-cli --server server_id

Motivation: When troubleshooting network issues or comparing different speedtest.net servers, it can be beneficial to run speed tests to specific servers. This allows users to determine the performance of individual servers or compare results between them.

Explanation: The --server option specifies the speedtest.net server ID. Running the command with the server ID initiates the speed test to that specific server.

Example Output:

Retrieving server list...Testing from ISP (IP address: x.x.x.x)...Selecting server ID: xxxxxxxHosted by <Server Provider> [X.XX km]: 47.34 msTesting download speed........................................Download: 50.14 MbpsTesting upload speed..................................................Upload: 25.20 Mbps

Use case 8: Run a speed test and display the results as JSON

Code:

speedtest-cli --json

Motivation: Getting the speed test results in a structured format like JSON can facilitate automating or integrating the information into other tools or systems. It allows for easier parsing and extracting specific data points programmatically.

Explanation: The --json option instructs speedtest-cli to return the speed test results in JSON format rather than the default human-readable format. This suppresses progress information during the test.

Example Output:

{ "download": 50140000, "upload": 25200000, "ping": 47.34, "server": { "url": "<Server URL>", "lat": "X.XXXXXXXXXX", "lon": "X.XXXXXXXXXX", "name": "<Server Name>", "country": "United States", "cc": "US", "sponsor": "<Server Provider>", "id": "xxxxxxxxxx", "host": "<Server Host>", "d": X.XX, "latency": 47.34 }, ...}

Speedtest-cli is a powerful command-line tool for testing internet bandwidth using speedtest.net servers. It offers a wide range of options to customize the speed test and obtain results in different formats. Whether users need a quick analysis of their network performance or want to delve into more specific details, speedtest-cli provides the necessary flexibility and information.

How to use the command speedtest-cli (with examples) (2024)
Top Articles
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 6051

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.