What happened:
After updating to 7.4, grafana listening on IPv6 addresses fail to start, with the following log messages:
t=2021-02-05T12:26:29+0100 lvl=eror msg="Stopped HTTPServer" logger=server reason="failed to open listener on address [[::1]]:3000: listen tcp: address [[::1]]:3000: missing port in address"
t=2021-02-05T12:26:29+0100 lvl=eror msg="A service failed" logger=server err="failed to open listener on address [[::1]]:3000: listen tcp: address [[::1]]:3000: missing port in address"
t=2021-02-05T12:26:29+0100 lvl=eror msg="Server shutdown" logger=server reason="failed to open listener on address [[::1]]:3000: listen tcp: address [[::1]]:3000: missing port in address"
failed to open listener on address [[::1]]:3000: listen tcp: address [[::1]]:3000: missing port in address
What you expected to happen:
Grafana configs that listened on IPv6 on 7.3 continue to work on 7.4 unless otherwise noted
How to reproduce it (as minimally and precisely as possible):
Use the following config under 7.3 and 7.4:
[server]
domain = my-domain.tld
http_addr = [::1]
http_port = 3000
protocol = http
root_url = %%(protocol)s://%%(domain)s:%%(http_port)s/
After changing [::1]
to ::1
, it works under 7.4.
Anything else we need to know?:
Environment:
- Grafana version: 7.4
- Data source type & version: n/a
- OS Grafana is installed on: debian
- User OS & Browser: n/a
- Grafana plugins: n/a
- Others:
I think that fundamentally IPv6 addresses should not be enclosed in square brackets, except for when you join an address with a port (and the brackets are necessary to disambiguate the colons in the IPv6 address from the colon separating the address from the port. That’s why this bug happens. You can see from this example that
net.JoinHostPort
doesn’t do well with an IPv6 address enclosed in square brackets.I guess we can build in some tolerance though, where we strip enclosing brackets before calling
net.JoinHostPort
.It also sounds super weird BTW that the image renderer would require brackets around IPv6 addresses.