I have the same issue. As @MikeMcQ stated port 80 must be opened so Let's Encrypt may reach that but where does this port have to be redirected to?
Currently there is a nginx listening on port 80 that is implemented as a reverse proxy. Nginx is running in a docker container.
Now I try to start a certbot using this command:
root@server-alterlaptop:~/nginx/conf# docker run --name temp_certbot -v /data/certbot/letsencrypt:/etc/letsencrypt -v /data/certbot/www:/tmp/letsencrypt -p 80:80 -p 443:443 -v /data/servers-data/certbot/log:/var/log certbot/certbot:latest certonly --webroot --agree-tos --renew-by-default --preferred-challenges http-01 --server https://acme-v02.api.letsencrypt.org/directory --text --email mymail@gmail.com -w /tmp/letsencrypt -d schuldenuhren.net
As there is a nginx running on port 80 the container obviously could not start but when I take the nginx down letsdebug shows me, that a request to port 80 does not work.
I tried several tutorials but none of them helped me get this thing running.
This is my error message:
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='acme-staging-v02.api.letsencrypt.org', port=443): Max retries exceeded with url: /directory (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f952b2ca760>: Failed to establish a new connection: [Errno -3] Try again'))
And this is my docker-compose.yml:
version: '3'
services:
nginx:
image: nginx:latest
container_name: nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- /root/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- /root/nginx/conf:/etc/nginx/conf.d:ro
- /root/nginx/logs:/var/log/nginx
- /root/certbot/www:/var/www/certbot/:ro
certbot:
image: certbot/certbot:latest
container_name: certbot
volumes:
- /root/certbot/www/:/var/www/certbot/:rw
Edit
I have added the certbot log file:
2022-09-30 10:57:56,059:DEBUG:certbot._internal.main:certbot version: 1.30.0
2022-09-30 10:57:56,060:DEBUG:certbot._internal.main:Location of certbot entry point: /usr/local/bin/certbot
2022-09-30 10:57:56,060:DEBUG:certbot._internal.main:Arguments: ['--keep', '--webroot', '--webroot-path', '/var/www/certbot', '--email', 'kolloch.tim@web.de', '--agree-tos', '-d', 'schuldenuhren.net']
2022-09-30 10:57:56,060:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2022-09-30 10:57:56,077:DEBUG:certbot._internal.log:Root logging level set at 30
2022-09-30 10:57:56,078:DEBUG:certbot._internal.plugins.selection:Requested authenticator webroot and installer None
2022-09-30 10:57:56,081:DEBUG:certbot._internal.plugins.selection:Single candidate plugin: * webroot
Description: Place files in webroot directory
Interfaces: Authenticator, Plugin
Entry point: webroot = certbot._internal.plugins.webroot:Authenticator
Initialized: <certbot._internal.plugins.webroot.Authenticator object at 0x7f37b7947970>
Prep: True
2022-09-30 10:57:56,082:DEBUG:certbot._internal.plugins.selection:Selected authenticator <certbot._internal.plugins.webroot.Authenticator object at 0x7f37b7947970> and installer None
2022-09-30 10:57:56,082:INFO:certbot._internal.plugins.selection:Plugins selected: Authenticator webroot, Installer None
2022-09-30 10:57:56,489:DEBUG:acme.client:Sending GET request to https://acme-v02.api.letsencrypt.org/directory.
2022-09-30 10:57:56,491:DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org:443
2022-09-30 10:58:01,498:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 358, in connect
self.sock = conn = self._new_conn()
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f37b78806d0>: Failed to establish a new connection: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='acme-v02.api.letsencrypt.org', port=443): Max retries exceeded with url: /directory (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f37b78806d0>: Failed to establish a new connection: [Errno -3] Try again'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/certbot", line 33, in <module>
sys.exit(load_entry_point('certbot', 'console_scripts', 'certbot')())
File "/opt/certbot/src/certbot/certbot/main.py", line 19, in main
return internal_main.main(cli_args)
File "/opt/certbot/src/certbot/certbot/_internal/main.py", line 1744, in main
return config.func(config, plugins)
File "/opt/certbot/src/certbot/certbot/_internal/main.py", line 1573, in certonly
le_client = _init_le_client(config, auth, installer)
File "/opt/certbot/src/certbot/certbot/_internal/main.py", line 827, in _init_le_client
acc, acme = _determine_account(config)
File "/opt/certbot/src/certbot/certbot/_internal/main.py", line 735, in _determine_account
acc, acme = client.register(
File "/opt/certbot/src/certbot/certbot/_internal/client.py", line 216, in register
acme = acme_from_config_key(config, key)
File "/opt/certbot/src/certbot/certbot/_internal/client.py", line 76, in acme_from_config_key
client = acme_client.BackwardsCompatibleClientV2(net, key, config.server)
File "/opt/certbot/src/acme/acme/client.py", line 891, in __init__
directory = messages.Directory.from_json(net.get(server).json())
File "/opt/certbot/src/acme/acme/client.py", line 1256, in get
self._send_request('GET', url, **kwargs), content_type=content_type)
File "/opt/certbot/src/acme/acme/client.py", line 1194, in _send_request
response = self.session.request(method, url, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 565, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='acme-v02.api.letsencrypt.org', port=443): Max retries exceeded with url: /directory (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f37b78806d0>: Failed to establish a new connection: [Errno -3] Try again'))
2022-09-30 10:58:01,502:ERROR:certbot._internal.log:An unexpected error occurred:
2022-09-30 10:58:01,502:ERROR:certbot._internal.log:requests.exceptions.ConnectionError: HTTPSConnectionPool(host='acme-v02.api.letsencrypt.org', port=443): Max retries exceeded with url: /directory (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f37b78806d0>: Failed to establish a new connection: [Errno -3] Try again'))