[Unraid] "Host not found" when using container name in proxy-conf file, works when using IP

I’m working on getting my containers set up via name instead of ip in the Swag container proxy-conf files (so that it doesn’t matter when their IPs change if I have to reboot the server), and I’m running into an issue.

When using the container name as is default (sonarr in this example), I get a “502 Nginx can not connect to the application” page in my browser (even after clearing cache), and this error in the Nginx error.log:
sonarr could not be resolved (3: Host not found), client: <my ip here>, server: _, request: "GET /sonarr/ HTTP/2.0", host: "mydomain.com", referrer: "https:/mydomain.com/sonarr/login?returnUrl=/sonarr/"

I also get the same issue when connecting directly to my Unraid server’s local IP/sonarr, so I don’t think it’s a domain name thing (I’m using Cloudflare - DNS off for testing currently)

When I edit the $upstream_app to use the Sonarr container’s internal IP shown in Unraid 172.x.x.x, it works fine. (I’m just using the included sonarr.subfolder.conf; this exact same issue also occurs when using nextcloud.subdomain.conf so it’s not just a subfolder thing)

Running docker exec swag ping sonarr -c2 also works without issue:

PING sonarr (172.x.x.x): 56 data bytes
64 bytes from 172.x.x.x: seq=0 ttl=64 time=0.075 ms
64 bytes from 172.x.x.x: seq=1 ttl=64 time=0.065 ms

--- sonarr ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.065/0.070/0.075 ms

I’ve got a custom Docker network (named proxynet) set up in Unraid as shown in SpaceInvador One’s video here (which is for the older Let’sEncrypt container but it seems to be similar), and Swag and Sonarr are both set up to use it. (Preserve user defined network: is set to Yes, and I’ve rebooted to confirm)

Not entirely sure what I’m doing wrong here, or what else to look for, as it seems the containers can communicate (from ping), but Nginx isn’t resolving the name correctly. Any guidance would be greatly appreciated!

1 Like

share the sonarr.subdomain.conf please. use the codeblock :slight_smile:

sonarr.subfolder.conf (not using sonarr.subdomain.conf, there is only sonarr.subdomain.conf.sample):

## Version 2021/05/18
# first go into sonarr settings, under "General" set the URL Base to /sonarr and restart the sonarr container

location ^~ /sonarr {
    # enable the next two lines for http auth
    #auth_basic "Restricted";
    #auth_basic_user_file /config/nginx/.htpasswd;

    # enable the next two lines for ldap auth, also customize and enable ldap.conf in the default conf
    #auth_request /auth;
    #error_page 401 =200 /ldaplogin;

    # enable for Authelia, also enable authelia-server.conf in the default site config
    #include /config/nginx/authelia-location.conf;

    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app sonarr;
    set $upstream_port 8989;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

}

location ^~ /sonarr/api {
    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app sonarr;
    set $upstream_port 8989;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

}

Solved, for anyone who sees this in the future!
Big thanks to @Roxedus#2021 in the LSIO discord, just delete /config/nginx/resolver.conf in the Swag container, and restart it!

That reset the resolver to 127.0.0.11 and now using the container names works perfectly. Not sure how it was wrong in the first place (maybe because I didn’t have Swag on the custom docker network at first), but that makes sense.

1 Like

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