How to disable ipv6 in nginx?

rough lea roughlea at
Thu Nov 15 11:10:08 UTC 2018


I am a newbie running tusd server on macos High Sierra behind an Nginx Proxy running within a docker container. In the logs, I notice that before an _UploadCreated_ event is received there is an attempt to connect to tusd using ipv6 loopback address which fails. 

_[crit] 23#23: *4 connect() to [::1]:1080 failed (99: Address not available) while connecting to upstream, client:, server: , request: "POST /files/ HTTP/1.1", upstream: "http://[::1]:1080/files/", host: ""_

My nginx configuration is listed below…..

server {
  listen                          1081 ssl http2;
  #listen [::]:443 http2 ipv6only=on ssl;
  charset                         utf-8;

  access_log                      /dev/stdout;
  error_log                       /dev/stdout;

  ssl_certificate                 /server/certs/tls.crt;
  ssl_certificate_key             /server/certs/tls.key;

  location /files/ {

    #resolver ipv6only=off;

    proxy_pass  http://localhost:1080/files/;
    #proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;

    # Disable request and response buffering
    proxy_request_buffering  off;
    proxy_buffering          off;
    proxy_http_version       1.1;

    # Add X-Forwarded-* headers so that response can reference https and
    # originating host:port
    proxy_set_header X-Forwarded-Host $host:$server_port;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # Allow proxying of websockets if required
    proxy_set_header         Upgrade $http_upgrade;
    proxy_set_header         Connection "upgrade";
    client_max_body_size     0;

If I take out the line, _listen                          [::]:1081 http2 ipv6only=on ssl;_ from the server config block, the issue still occurs. 

Upon further reading at [docker]( and [docker-for-mac](, it appears that ipv6 networking is only available for docker daemons running on Linux hosts???

I have tried adding a resolver and setting ipv6only=off but nginx seems to continue to try and send to the upstream proxy with an ipv6 address. 

How can I get nginx to use ipv4 only? Has anybody else experienced and resolved the same issue?

Kind regards


More information about the nginx mailing list