Timeout after connect (your server may be slow or overloaded)

Here you go. Also, a big thank you in advance for assisting me.

# configuration file /etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
worker_rlimit_nofile 1000000;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        multi_accept on;
        use epoll;
	worker_connections 1000000;
	# multi_accept on;
}

http {

	##
	# Basic Settings
	##

        client_max_body_size 50M;
	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 120;
        keepalive_requests 10000;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# SSL Settings
	##

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}

# configuration file /etc/nginx/modules-enabled/50-mod-http-geoip.conf:
load_module modules/ngx_http_geoip_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-image-filter.conf:
load_module modules/ngx_http_image_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-xslt-filter.conf:
load_module modules/ngx_http_xslt_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-mail.conf:
load_module modules/ngx_mail_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-stream.conf:
load_module modules/ngx_stream_module.so;

# configuration file /etc/nginx/mime.types:

types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/javascript                js;
    application/atom+xml                  atom;
    application/rss+xml                   rss;

    text/mathml                           mml;
    text/plain                            txt;
    text/vnd.sun.j2me.app-descriptor      jad;
    text/vnd.wap.wml                      wml;
    text/x-component                      htc;

    image/png                             png;
    image/tiff                            tif tiff;
    image/vnd.wap.wbmp                    wbmp;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;
    image/svg+xml                         svg svgz;
    image/webp                            webp;

    application/font-woff                 woff;
    application/java-archive              jar war ear;
    application/json                      json;
    application/mac-binhex40              hqx;
    application/msword                    doc;
    application/pdf                       pdf;
    application/postscript                ps eps ai;
    application/rtf                       rtf;
    application/vnd.apple.mpegurl         m3u8;
    application/vnd.ms-excel              xls;
    application/vnd.ms-fontobject         eot;
    application/vnd.ms-powerpoint         ppt;
    application/vnd.wap.wmlc              wmlc;
    application/vnd.google-earth.kml+xml  kml;
    application/vnd.google-earth.kmz      kmz;
    application/x-7z-compressed           7z;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/xhtml+xml                 xhtml;
    application/xspf+xml                  xspf;
    application/zip                       zip;

    application/octet-stream              bin exe dll;
    application/octet-stream              deb;
    application/octet-stream              dmg;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;

    application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;
    application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;

    audio/midi                            mid midi kar;
    audio/mpeg                            mp3;
    audio/ogg                             ogg;
    audio/x-m4a                           m4a;
    audio/x-realaudio                     ra;

    video/3gpp                            3gpp 3gp;
    video/mp2t                            ts;
    video/mp4                             mp4;
    video/mpeg                            mpeg mpg;
    video/quicktime                       mov;
    video/webm                            webm;
    video/x-flv                           flv;
    video/x-m4v                           m4v;
    video/x-mng                           mng;
    video/x-ms-asf                        asx asf;
    video/x-ms-wmv                        wmv;
    video/x-msvideo                       avi;
}

# configuration file /etc/nginx/conf.d/example-cache.conf:
proxy_cache_path /tmp/example-cache/ levels=1:2 keys_zone=example-cache:16m max_size=10g inactive=60m use_temp_path=off;


# configuration file /etc/nginx/sites-enabled/default:
# HTTP — redirect all traffic to HTTPS
server {
    listen 80;
    listen [::]:80;
    server_name prsnl-server.com;
    return 301 https://$host$request_uri;
}

#upstream my_http_servers {
    #ip_hash;
#    server 127.0.0.1:5000;      # httpServer1 listens to port 444
#    server 127.0.0.1:5001;      # httpServer2 listens to port 445
#}

# HTTPS — proxy all requests to the Node app
server {
    # Enable HTTP/2
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name prsnl-server.com;

    # Use the Let’s Encrypt certificates
    ssl_certificate /etc/letsencrypt/live/prsnl-server.com-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/prsnl-server.com-0001/privkey.pem; # managed by Certbot

    # Include the SSL configuration from cipherli.st
    include snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
       # proxy_pass http://my_http_servers;
        proxy_pass http://localhost:5000;
       # proxy_set_header Upgrade $http_upgrade;
       # proxy_set_header Connection "upgrade";
       # proxy_http_version 1.1;
       # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       # proxy_set_header Host $host;
    }


}

# HTTPS — proxy all requests to the Node app
server {
    # Enable HTTP/2
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.prsnl-server.com;

    # Use the Let’s Encrypt certificates
    ssl_certificate /etc/letsencrypt/live/www.prsnl-server.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.prsnl-server.com/privkey.pem; # managed by Certbot

    # Include the SSL configuration from cipherli.st
    include snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
        # proxy_pass http://my_http_servers;
        proxy_pass http://localhost:5000;
        # proxy_set_header Upgrade $http_upgrade;
        # proxy_set_header Connection "upgrade";
        # proxy_http_version 1.1;
        # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        # proxy_set_header Host $host;
    }

}



server {
    server_name files.prsnl-server.com;

    location / {
        proxy_pass https://prsnl.ams3.cdn.digitaloceanspaces.com/;
        proxy_hide_header      Strict-Transport-Security;
        proxy_cache            example-cache;
        proxy_cache_valid      200 1440m;
        proxy_cache_use_stale  error timeout updating http_500 http_502 http_503 http_504;
        proxy_cache_revalidate on;
        proxy_cache_lock       on;
        proxy_ignore_headers   Set-Cookie;
        add_header             X-Cache-Status $upstream_cache_status;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/prsnl-server.com-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/prsnl-server.com-0001/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

#server {
#    server_name www.files.prsnl-server.com;
#
#    location / {
#        proxy_pass https://prsnl.ams3.cdn.digitaloceanspaces.com/;
#        proxy_hide_header      Strict-Transport-Security;
#        proxy_cache            example-cache;
#        proxy_cache_valid      200 1440m;
#        proxy_cache_use_stale  error timeout updating http_500 http_502 http_503 http_504;
#        proxy_cache_revalidate on;
#        proxy_cache_lock       on;
#        proxy_ignore_headers   Set-Cookie;
#        add_header             X-Cache-Status $upstream_cache_status;
#    }
#
#    listen [::]:443 ssl ipv6only=on; # managed by Certbot
#    listen 443 ssl; # managed by Certbot
#    ssl_certificate /etc/letsencrypt/live/www.files.prsnl-server.com/fullchain.pem; # managed by Certbot
#    ssl_certificate_key /etc/letsencrypt/live/www.files.prsnl-server.com/privkey.pem; # managed by Certbot
#    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
#    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
#
#}


# configuration file /etc/nginx/snippets/ssl-params.conf:
# See https://cipherli.st/ for details on this configuration
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off; # Requires nginx >= 1.5.9
ssl_stapling on; # Requires nginx >= 1.3.7
ssl_stapling_verify on; # Requires nginx => 1.3.7
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;

# Add our strong Diffie-Hellman group
ssl_dhparam /etc/ssl/certs/dhparam.pem;

# configuration file /etc/letsencrypt/options-ssl-nginx.conf:
# This file contains important security parameters. If you modify this file
# manually, Certbot will be unable to automatically provide future security
# updates. Instead, Certbot will print and log an error message with a path to
# the up-to-date file that you will need to refer to when manually updating
# this file.

ssl_session_cache shared:le_nginx_SSL:1m;
ssl_session_timeout 1440m;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS";

I’m not sure. I tried running with your exact config on an Ubuntu 18 system with the same Certbot version, and it worked okay for me.

I’m kind of suspicious of the most recent “hung” Certbot you got, because it’s sort of the same symptom as the original problem you reported - “timeout after connect”. Both of them are hangs on network i/o but in different contexts (originally LE validation server talking to your server, and now your server talking to LE API). Maybe the problem is in the network after all, but it doesn’t really seem likely that something is busted on DigitalOcean’s network unless you’ve been messing with some sysctls or MTUs or whatever.

Quite possibly we’ve been barking up the wrong tree with the authenticators and that there’s nothing wrong on the Certbot/nginx side after all.

Hmm, strange. Especially the exact config working fine for you. Should I contact DO? Is there anything else I can do? I can’t think of anything I’ve changed sysctl / MTU related.

FYI: I also asked for help on the DigitalOcean community. Link: https://www.digitalocean.com/community/questions/timeout-after-connect-your-server-may-be-slow-or-overloaded

Does anybody have an idea? My cert will be invalid in 6 days… hope I’ll find a solution.

Hi @PennyWise94

your url

https://acme-v02.api.letsencrypt.org/acme/authz-v3/5809362364

has the answer.

"Invalid response from https://files.prsnl-server.com/.well-known/acme-challenge/ze36pg2_VLRc9QPbaDgzBXWw464pWCYaKhc5NvFUzpM [128.199.34.6]: "<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>AccessDeniedprsnltx00000000000000e""

url "https://files.prsnl-server.com/.well-known/acme-challenge/ze36pg2_VLRc9QPbaDgzBXWw464pWCYaKhc5NvFUzpM"
hostname "files.prsnl-server.com"
port "443"
addressesResolved
0 "128.199.34.6"
addressUsed "128.199.34.6"

Do you run your Certbot on that ip 128.199.34.6? If not, that can't work.

You can always use --manual + dns validation to create a new certificate. It's manual, but it should always work. Then you have 90 days to find a solution.

Yes. I am connected to root@128.199.34.6.

Could it, somehow, have to do with the fact that I have, for this droplet, private IP enabled?

AccessDenied

Webroot with Access is required. I don't know if your running Certbot is able to change the webserver configuration of that system, so --apache or --nginx may not work.

<Error>
<Code>AccessDenied</Code>
<BucketName>prsnl</BucketName>
<RequestId>tx000000000000010d4aba4-005f0b5ce8-1ee1997-ams3a</RequestId>
<HostId>1ee1997-ams3a-ams3</HostId>
</Error>

But webroot with access should work.

Lol. I think I figured it out, because of your comment @JuergenAuer.

I was looking in my control panel and figured the private IP was enabled. That wasn’t and shouldn’t be a big deal.

However, I also noticed ipv6 was not enabled. While ipv6only=on for authentication. I just turned on ipv6 in the control panel, restarted nginx, ran certbot renew --force-renewal and ta-daa:

Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/prsnl-server.com-0001/fullchain.pem (success)
  /etc/letsencrypt/live/prsnl-server.com/fullchain.pem (success)
  /etc/letsencrypt/live/www.files.prsnl-server.com/fullchain.pem (success)
  /etc/letsencrypt/live/www.prsnl-server.com/fullchain.pem (success)

Can you confirm this was the issue? ipv6 being turned off?

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