An unexpected error occurred:

I’m trying to generate certificate for my domain with virtualmin.

I get this error:

… request failed : Web-based validation failed :

Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator webroot, Installer None Starting new HTTPS connection (1): An unexpected error occurred: TypeError: str returned non-string (type Error) Please see the logfiles in /var/log/letsencrypt for more details.

DNS-based validation failed :

Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator manual, Installer None Starting new HTTPS connection (1): An unexpected error occurred: TypeError: str returned non-string (type Error) Please see the logfiles in /var/log/letsencrypt for more details.

Checking the log, nothing is clear for me.

2020-04-13 16:45:48,484:DEBUG:certbot._internal.main:certbot version: 1.3.0
2020-04-13 16:45:48,484:DEBUG:certbot._internal.main:Arguments: [’–manual’, ‘-d’, ‘’, ‘-d’, ‘’, ‘–preferred-challenges=dns’, ‘–manual-auth-hook’, ‘/etc/webmin/webmin/’, ‘–manual-cleanup-hook’, ‘/etc/webmin/webmin/’, ‘–duplicate’, ‘–force-renewal’, ‘–manual-public-ip-logging-ok’, ‘–non-interactive’, ‘–agree-tos’, ‘–config’, ‘/tmp/.webmin/379363_13631_3_letsencrypt.cgi’, ‘–rsa-key-size’, ‘2048’, ‘–cert-name’, ‘’]
2020-04-13 16:45:48,484:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2020-04-13 16:45:48,502:DEBUG:certbot._internal.log:Root logging level set at 20
2020-04-13 16:45:48,502:INFO:certbot._internal.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2020-04-13 16:45:48,503:DEBUG:certbot._internal.plugins.selection:Requested authenticator manual and installer None
2020-04-13 16:45:48,504:DEBUG:certbot._internal.plugins.selection:Single candidate plugin: * manual
Description: Manual configuration or run your own shell scripts
Interfaces: IAuthenticator, IPlugin
Entry point: manual = certbot._internal.plugins.manual:Authenticator
Initialized: <certbot._internal.plugins.manual.Authenticator object at 0x7f855bcd8e90>
Prep: True
2020-04-13 16:45:48,504:DEBUG:certbot._internal.plugins.selection:Selected authenticator <certbot._internal.plugins.manual.Authenticator object at 0x7f855bcd8e90> and installer None
2020-04-13 16:45:48,504:INFO:certbot._internal.plugins.selection:Plugins selected: Authenticator manual, Installer None
2020-04-13 16:45:48,527:DEBUG:certbot._internal.main:Picked account: <Account(RegistrationResource(body=Registration(status=None, terms_of_service_agreed=None, agreement=None, only_return_existing=None, contact=(), key=None, external_account_binding=None), uri=u’’, new_authzr_uri=None, terms_of_service=None), eb9a6097073c529863052fb818b77443, Meta(creation_host=u’’, creation_dt=datetime.datetime(2020, 4, 10, 15, 13, 17, tzinfo=)))>
2020-04-13 16:45:48,529:DEBUG:acme.client:Sending GET request to
2020-04-13 16:45:48,541:INFO:urllib3.connectionpool:Starting new HTTPS connection (1):
2020-04-13 16:45:48,573:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
File “/bin/letsencrypt”, line 9, in
load_entry_point(‘certbot==1.3.0’, ‘console_scripts’, ‘certbot’)()
File “/usr/lib/python2.7/site-packages/certbot/”, line 15, in main
return internal_main.main(cli_args)
File “/usr/lib/python2.7/site-packages/certbot/_internal/”, line 1347, in main
return config.func(config, plugins)
File “/usr/lib/python2.7/site-packages/certbot/_internal/”, line 1217, in certonly
le_client = _init_le_client(config, auth, installer)
File “/usr/lib/python2.7/site-packages/certbot/_internal/”, line 610, in _init_le_client
return client.Client(config, acc, authenticator, installer, acme=acme)
File “/usr/lib/python2.7/site-packages/certbot/_internal/”, line 257, in init
acme = acme_from_config_key(config, self.account.key, self.account.regr)
File “/usr/lib/python2.7/site-packages/certbot/_internal/”, line 44, in acme_from_config_key
return acme_client.BackwardsCompatibleClientV2(net, key, config.server)
File “/usr/lib/python2.7/site-packages/acme/”, line 808, in init
directory = messages.Directory.from_json(net.get(server).json())
File “/usr/lib/python2.7/site-packages/acme/”, line 1141, in get
self._send_request(‘GET’, url, **kwargs), content_type=content_type)
File “/usr/lib/python2.7/site-packages/acme/”, line 1091, in _send_request
response = self.session.request(method, url, *args, **kwargs)
File “/usr/lib/python2.7/site-packages/requests/”, line 486, in request
resp = self.send(prep, **send_kwargs)
File “/usr/lib/python2.7/site-packages/requests/”, line 598, in send
r = adapter.send(request, **kwargs)
File “/usr/lib/python2.7/site-packages/requests/”, line 370, in send
File “/usr/lib/python2.7/site-packages/urllib3/”, line 544, in urlopen
body=body, headers=headers)
File “/usr/lib/python2.7/site-packages/urllib3/”, line 344, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File “/usr/lib/python2.7/site-packages/urllib3/”, line 314, in _raise_timeout
if ‘timed out’ in str(err) or ‘did not complete (read)’ in str(err): # Python 2.6
TypeError: str returned non-string (type Error)
2020-04-13 16:45:48,575:ERROR:certbot._internal.log:An unexpected error occurred:

Any clue?thx

1 Like

First, to solve this specific error, it seems you need to upgrade urllib3. (Or, potentially, requests, which can include its own copy of urllib3 – you’re currently using an independent urllib3, though.)

What OS are you on? If you’re lucky, there might be an update available. If there isn’t, it may be best to use certbot-auto (which installs Python dependencies separately in a virtual environment) or upgrade to a newer release of your OS, which might happen to package a newer requests or urllib3.

Second, this error may or may not be important: something went wrong, then this bug is in the urllib3 error handling. Fixing it may just reveal what the original error is and leave you to solve that. Instead, if you can somehow figure out what network problem is happening, you might be able to resolve or work around it and ignore the error handling bug.

(Edits: Expanded the post.)

1 Like

Well, is wired, because yesterday worked.

My OS is CentOS Linux 7.7.1908

1 Like

There might be some kind of coincidental, temporary problem with the Internet between you and the API.

1 Like

OK. I’ll wait and trying again later.

One more question, pls.
Before use let’s encrypt cert I was using a self-signed cert.
I requested an let’s encrypt cert… and it is still using old cert. I’ve deleted from /home/mydoimainname/ were was and still showing me that old one.

1 Like

Hi there. I came back after taking your advice “There might be some kind of coincidental, temporary problem with the Internet between you and the API.” and still does sending back the same error

Any other clues? Thx

1 Like

I also have this problem in CentOS 7.
In other server that it works, certbot --version shows 0.36. In the server that throws this error, certbot --version shows 1.3
It has been working without problems until some days ago… I don’t know really what the problem is, but I cannot add new certificates nor renew the existing ones.

As @viper_tkd says, any clue is welcome. I’ve upgraded all the upgradeable things… :frowning:
Thanks in advance

@rafaelo did you find the solution on this issue?

Not at all @viper_tkd. I’ve checked if there is an update for certbot, but it is not the case. It’s very frustrating… Do you have any new info?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.