Skip to content

Connection timed out errors #72

@jlyonsmith

Description

@jlyonsmith

I'm getting:

2019/01/17 21:38:32 [error] 4213#4213: *12683 upstream timed out (110: Connection timed out) while connecting to upstream(proxy_connect), client: 192.168.0.138, server: , request: "CONNECT registry.npmjs.org:443 HTTP/1.1", host: "registry.npmjs.org"

When trying to do an npm install through the proxy. What happens is, I will get may a hundred or so successful upstream connections, and then this error will start to appear and npm will never recover.

Both my systems are on AWS EC2. My nginx.conf file looks like this:

worker_processes 1;

error_log /var/log/nginx/error.log info;

pid /run/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include mime.types;
  default_type application/octet-stream;
  sendfile on;
  keepalive_timeout 65;

  server {
    listen 3128;
    resolver 127.0.0.53 ipv6=off;
    resolver_timeout 30s;

    # Forward proxy for CONNECT requests
    proxy_connect;
    proxy_connect_allow 443;
    proxy_connect_connect_timeout 30s;
    proxy_connect_read_timeout 30s;
    proxy_connect_send_timeout 30s;

    # Forward proxy for non-CONNECT request
    location / {
      proxy_pass http://$host;
      proxy_set_header Host $host;
    }
  }
}

I found I had to add the ipv6=off or the I'd get this error almost constantly. Apparently there is a race condition with the DNS server sometimes returning an IPv6 record before the IPv4 one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions