Speedtest CLI: Resolving HTTP Error 403 Forbidden

Learn how to check internet speed from the terminal and fix HTTP 403 errors with Speedtest CLI.

After setting up networking on my headless Raspberry Pi, I wanted to verify that my internet connection was working properly. To do this, I used the Python tool speedtest-cli.

You can install speedtest-cli by using uv:

uv tool install speedtest-cli

Or the classic pip:

pip install speedtest-cli

However, when I tried to check my internet speed using the command-line tool, I encountered an HTTP Error 403:

$ speedtest
Retrieving speedtest.net configuration...
Cannot retrieve speedtest configuration
ERROR: HTTP Error 403: Forbidden

I’m not sure what caused this, but my best guess is that the error occurs when the tool attempts to access speedtest.net servers over HTTP (port 80) instead of HTTPS (port 443), and the server refuses the connection.

Solution

To resolve this, simply run speedtest with the --secure parameter. According to the documentation, this forces the tool to use HTTPS for all communications with speedtest.net servers.

speedtest --secure

Here’s an example of a successful terminal session after using secure mode. Instead of the 403 error, I received the expected speed test results:

$ speedtest --secure
Retrieving speedtest.net configuration...
Testing from MyRepublic Indonesia (203.0.113.1)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by PT Metrosolusi Teknologi Indonesia (Malang) [82.45 km]: 26.221 ms
Testing download speed.......................................................
Download: 46.39 Mbit/s
Testing upload speed.........................................................
Upload: 53.87 Mbit/s

That’s all for today. Thanks for reading!

References