How to Test Your Internet Speed Bidirectionally from Command Line Using ‘Speedtest-CLI’ Tool

We always need to check the speed of the Internet connection at home and office. What we do for this? Go to websites like and begin test. It loads JavaScript in the web browser and then select best server based upon ping and output the result. It also uses a Flash player to produce graphical results.

What about headless server, where isn’t any web based browser and the main point is, most of the servers are headless. The another bottleneck of such web browser based speed testing is that, you can’t schedule the speed testing at regular interval. Here comes an application “Speedtest-cli” that removes such bottlenecks and let you test the speed of Internet connection from command line.

What is Speedtest-cli

The application is basically a script developed in Python programming Language. It measures Internet Bandwidth speed bidirectionally. It used infrastructure to measure the speed. Speedtest-cli is able to list server based upon physical distance, test against specific server, and gives you URL to share the result of your internet speed test.

To install latest speedtest-cli tool in Linux systems, you must have Python 2.4-3.4 or higher version installed on the system.

Install speedtest-cli in Linux

There are two ways to install speedtest-cli tool. The first method involves the use of python-pip package while the second method is to download the Python script, make it executable and run, here I will cover both ways….

Install speedtest-cli Using pythin-pip

First you need to install python-pip package, then afterwards you can install the speedtest-cli tool using pip command as shown below.

$ sudo apt-get install python-pip
$ sudo pip install speedtest-cli

To upgrade speedtest-cli, at later stage, use.

$ sudo pip install speedtest-cli --upgrade

Install speedtest-cli Using Python Script

First download the python script from github using wget command, unpack the downloaded file ( and extract it..

$ wget
$ unzip 

After extracting the file, go to the extracted directory speedtest-cli-master and make the script file executable.

$ cd speedtest-cli-master/
$ chmod 755 

Next, move the executable to /usr/bin folder, so that you don’t need to type the full path everytime.

$ sudo mv /usr/bin/

Testing Internet Connection Speed with speedtest-cli

1. To test Download and Upload speed of your internet connection, run the speedtest-cli command without any argument as shown below.

Test Download Upload Speed in Linux

Test Download Upload Speed in Linux

2. To check the speed result in bytes in place of bits.

$ --bytes
Test Internet Speed in Bytes

Test Internet Speed in Bytes

3. Share your bandwidth speed with your friends or family. You are provided with a link that can be used to download an image.

# --share
Share Internet Speed Results

Share Internet Speed Results

The following picture is a sample speed test result generated using above command.

Speed Test Results

Speed Test Results

4. Don’t need any additional information other than Ping, Download and upload?

$ --simple
Test Ping Download Upload Speed

Test Ping Download Upload Speed

5. List the server based upon physical distance. The distance in km is mentioned.

$ --list
Check Servers

Check Servers

6. The last stage generated a huge list of servers sorted on the basis of distance. How to get desired output? Say I only want to see the server located in Mumbai (India).

$ --list | grep -i Mumbai
Check Nearest Server

Check Nearest Server

7. Test connection speed against a specific server. Use Server Id generated in example 5 and example 6 in above.

$ --server [server ID]
$ --server [5060]              ## Here server ID 5060 is used in the example.
Test Connection Against Server

Test Connection Against Server

8. To check the version number and help of speedtest-cli tool.

$ --version
Check SpeedCli Version

Check SpeedCli Version

$ --help
SpeedCli Help

SpeedCli Help

Note: Latency reported by tool is not its goal and one should not rely on it. The relative latency values output is responsible for server selected to be tested against. CPU and Memory capacity will influence the result to certain extent.


The tool is must for system administrators and developers. A simple script which runs without any issue. I must say that the application is wonderful, lightweight and do what it promises. I disliked for the reason it was using flash, but speedtest-cli gave me a reason to love them.

speedtest_cli is a third party application and should not be used to automatically record the bandwidth speed. is used by millions of users and it is a good idea to Set Your Own Speedtest Mini Server.

That’s all for now, till then stay tuned and connected to Tecmint. Don’t forget to give your valuable feedback in the comments below. Like and share us and help us get spread.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

40 Responses

  1. leonardo says:

    @avishek, great job!
    But im specting error ” Failed to retrieve list of servers ”
    Just try to find line 345 but not found the code. ive installed from PIP install

    [email protected]:/usr/local/lib/python2.7/dist-packages# ls
    speedtest_cli-0.3.2.egg-info speedtest_cli.pyc

    [email protected]:/usr/local/lib/python2.7/dist-packages# ./ –version

    On Line 384 i have this code:

    urls = [


  2. DumasLinux says:

    If you do not have python in OS:

    Another way to test the speed at servers from Linux CLI (without python) :

  3. Rodel Catajay says:

    I installed using pip. run the command, but the respond is “Command not found.”
    I’m using Ubuntu 14.04

  4. schbax says:

    just FYI, on FreeBSD 10.1-STABLE the script fails because it cannot retrieve the list :

    Retrieving configuration…
    Could not retrieve configuration

    Any ideas why?
    Python version is 2.7.9

    • Avishek Kumar says:

      Have u installed PIP?
      Followed the installation instruction from top to bottom?
      remove the downloaded package and Download the package once again.
      If problem still persists, report us with your distribution and version information and we would be happy to help.

      P.S : Hope nothing is messed up in DNS. :P

    • Scott says:

      You need to install the ca_root_nss package/port. It’s failing to verify the SSL cert.

  5. Vit Tobek says:

    My result using Speedtest-CLI was D: 11.03 U: 4.47
    When I test it using browser (chrome on, my result is D:29.20 U: 30.55 (this is expected result)
    Why the difference?

    • Avishek Kumar says:

      Though it is very strange since Speedteest-CLI uses the same engine as, I have got similar feedback from a few users. Moreover it is possible that ISP is playing nasty with certain speedtest sites or the application is buggy.

  6. Lizbeth says:

    The command didn’t work as reported. I itried with no success. I instead was able to get results with just speedtest-cli at the command prompt. Just an fyi.

    It works exactly as you said otherwise and looks quite handy. thanks!

    • Avishek Kumar says:

      Would you please tell us the distribution and version you have installed. Also let us know how you installed the package?
      Thanks for taking the time and commenting.

  7. Henrique Nunnes says:

    For Arch Linux we have aur pkg and it’s working really fine.

  8. Kiran Patil says:

    Good tutorial, I am using this, for monitoring the ISP’s speed.
    Thanks you for the article.

  9. jtgd says:

    All I get is:

    $ speedtest-cli
    Retrieving configuration…
    Retrieving server list…
    Failed to parse list of servers

    • james says:

      I get the same:

      OS : CENTOS 6.6

      Retrieving configuration…
      Retrieving server list…
      Failed to retrieve list of servers

      • Avishek Kumar says:

        Change line 345 in the script

        uh = urlopen(‘’)


        uh = urlopen(‘’)

        save and exit. Try running speedtest-cli again. It should work.


    • Magnus says:

      Me to on my Ubuntu server.. =(

      • Avishek Kumar says:

        Change line 345 in the script

        uh = urlopen(‘’)


        uh = urlopen(‘’)

        save and exit. Try running speedtest-cli again. It should work.


    • Avishek Kumar says:

      Change line 345 in the script

      uh = urlopen(‘’)


      uh = urlopen(‘’)

      save and exit. Try running speedtest-cli again. It should work.


  10. Sergey Kolchenko says:

    I think, this kind of utility must be written in C, not in Python. I don’t want to install package managers, like pip. I’d like to execute binaries!

    • Perry H says:

      Why would you want to write something in C that doesn’t need to be?

      btw, Arch linux has a package in the AUR for this, and it works just like any other binary. You should check with your distro to see if they have packaged it already.

      Also, author -> s/pythin-pip/python-pip/

    • Avishek Kumar says:

      Writing such application in C would be perhaps a tiresome job. Such applications are not meant to be written from scratch when you can use already developed small pieces of software.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.