netbirdio/netbird · error

invalid DNS address: %s

Error message

invalid DNS address: %s

What it means

DNSList.Add parses its argument with netip.ParseAddr, which accepts only bare IP literals. Anything else (hostname, URL, address:port, CIDR) fails and returns this error; on success the address is Unmap()ed and stored with dns.DefaultPort (53). Note the underlying ParseAddr error is discarded, so the message carries only the offending string.

Source

Thrown at client/android/dns_list.go:19

package android

import (
	"fmt"
	"net/netip"

	"github.com/netbirdio/netbird/client/internal/dns"
)

// DNSList is a wrapper of []netip.AddrPort with default DNS port
type DNSList struct {
	items []netip.AddrPort
}

// Add new DNS address to the collection, returns error if invalid
func (array *DNSList) Add(s string) error {
	addr, err := netip.ParseAddr(s)
	if err != nil {
		return fmt.Errorf("invalid DNS address: %s", s)
	}
	addrPort := netip.AddrPortFrom(addr.Unmap(), dns.DefaultPort)
	array.items = append(array.items, addrPort)
	return nil
}

// Get return an element of the collection as string
func (array *DNSList) Get(i int) (string, error) {
	if i >= len(array.items) || i < 0 {
		return "", fmt.Errorf("out of range")
	}
	return array.items[i].Addr().String(), nil
}

// Size return with the size of the collection
func (array *DNSList) Size() int {
	return len(array.items)
}

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Pass a plain IP literal: "1.1.1.1" or "2001:4860:4860::8888".
  2. Resolve hostnames to IPs in app code before calling Add.
  3. Validate input in the UI with netip.ParseAddr and reject or resolve it before it reaches DNSList.

Example fix

// before
err := dnsList.Add("dns.google")

// after
err := dnsList.Add("8.8.8.8")
Defensive patterns

Strategy: validation

Validate before calling

// Validate before adding to the DNS list
func validDNSAddr(s string) bool {
    addr, err := netip.ParseAddr(s)
    return err == nil && addr.IsValid()
}

Type guard

func isInvalidDNSAddress(err error) bool {
    return err != nil && strings.HasPrefix(err.Error(), "invalid DNS address:")
}

Try / catch

if err := dnsList.Add(input); err != nil {
    if isInvalidDNSAddress(err) {
        // show the user which value was rejected and prompt for a bare IP literal
        return fmt.Errorf("enter an IP address like 1.1.1.1, not a hostname")
    }
    return err
}

Prevention

When it happens

Trigger: Passing "dns.google" or "one.one.one.one" (hostnames); "1.1.1.1:53" (port included); "10.0.0.0/8" (CIDR); or a malformed IPv6 literal to DNSList.Add.

Common situations: Users typing DNS provider names into a mobile UI; feeding a config value that contains host:port; copying a CIDR from a route config into a DNS field.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/cd4c32f14413ea2c. Report an issue: GitHub.