Failing to download from Cloudflare with ConnectionRefusedError

Hello to all,

I have just found libretranslate and tried to install it on a virtual environment on a Tumbleweed and Ubuntu linux pc. Two different ones without success.

I always get the URLError(ConnectionRefusedError(111, 'Connection refused')) when trying to run the already installed server.

That said the installation completes successfully yet running libretranslate I get the error above.

Note as the server comes with several side packages I have not tried to install natively the server on each machine to see if it makes any difference. I used the venv to test it for start.

Please let me know if I have to install it on the machine and not on a venv or something else (like the firewall) is the problem.

Finally I do not know if this is the right Topic to post in. Please transfer this post to whatever topic is relevant.

Thank you in advance

Is there a firewall? You need to be able to download the models from cloudflare R2 (without any SSL tampering).

There is a firewall active.

I have tried to TCP/UDP enable the 5000 port for the server to be free on it but it did not work.

I may have to dig more into it (firewall config) though.

It is not the firewall. I did disable it altogether and I got the same result… posting it:

$ libretranslate --load-only en,el
Updating language models
Found 86 models
Keep 2 models
Downloading English → Greek (1.9) ...
(URLError(ConnectionRefusedError(111, 'Connection refused')),)
(URLError(ConnectionRefusedError(111, 'Connection refused')),)
(URLError(ConnectionRefusedError(111, 'Connection refused')),)
(URLError(ConnectionRefusedError(111, 'Connection refused')),)
Cannot update models (normal if you're offline): Download failed for English → Greek
Traceback (most recent call last):
  File "/home/lydia/Documents/ML_SiebelOptimization/.venv/bin/libretranslate", line 8, in <module>
  File "/home/lydia/Documents/ML_SiebelOptimization/.venv/lib/python3.10/site-packages/libretranslate/", line 206, in main
    app = create_app(args)
  File "/home/lydia/Documents/ML_SiebelOptimization/.venv/lib/python3.10/site-packages/libretranslate/", line 186, in create_app
    language_target_fallback = languages[1] if len(languages) >= 2 else languages[0]
IndexError: list index out of range

Please note that I installed normally on the system the server, run the libretranslate server (even disabled once more the firewall) and still get the same error. So it is not a specific problem concerning the virtual environment created in python.

Are these URLs accessible from the machine?

The first one you posted is not accessible with error: on FF “Unable to Connect”
The second one is accessible and seems to be a JSON list

Find out why the first one is not accessible, and the issue will get resolved.

In what country is the machine located ?

with curl I get the following message:

$ curl
curl: (7) Failed to connect to port 443 after 5 ms: Connection refused

The machine is in Greece

This is a bit of a hack but I currently mirror the argosmodel packages at and you can modify your local package index to point there if Cloudflare is blocking you. I don’t love relying on Cloudflare but Cloudflare is free for us and very fast.

Repoint local index

# Change local package index to
cd ~/.local/cache/argos-translate/
# Use sed to replace the string in the file
sed -i "s|$original_string|$replacement_string|g" index.json

Install all packages

Installing with LibreTranslate will flush our locally modified version of the package index so we need to install the packages manually.

#!/bin/env python
import argostranslate
import argostranslate.package
for p in argostranslate.package.get_available_packages():

I also wonder if assigning a (sub)domain name to the R2 bucket would alleviate this issue; I know it’s been affecting several people. Public buckets · Cloudflare R2 docs

What’s the benefit of a custom domain?

Argos Translate supports multiple links for packages so I could add a second link pointing to to the package index. Argos Translate currently uses random Round Robin when there are multiple links but I could change that in the code so the second link is just a failover in case Cloudflare fails.

Thank you very much!

I do not know if the bellow works (your code just added a progress bar) but it would be nice to see some progress while waiting…

import argostranslate
import argostranslate.package
from tqdm import tqdm
for p in argostranslate.package.get_available_packages():
    for i in tqdm(len(argostranslate.package.get_available_packages())):

Thank you once more!


I think it’s because the .dev domain gets blocked in some configurations. For Maximum Accessibility, Be Careful About Using a .dev Domain | Alex MacArthur

Assigning a different domain would get around it. It should be free to setup.

1 Like

Oh interesting!

I just registered the domain “” to use with Cloudflare.

1 Like

I updated the index. The new domain should be live now.

1 Like

Tested, seems to be working on my network! @markman8 can you access the new URLs in the index?

I will test it in the evening today since I am not on the machine right now.

I could give it a go and set up another server on a virtual environment if you like and see if the whole process completes

By index you mean the “links:” field in the JSON file in ?

Both https and ipfs? As for “” dir I get a 404 error which is reachable and normal.

Ignore the IPFS URLs, try this one:

You don’t need a separate virtualenv just open the link in your web browser to see if your firewall is blocking it.

It works. Download starts immediately without any problems.