Bad Gateway (nginx reverse proxy) when binding to localhost

I have Grafana running behind a nginx reverse proxy with the following configuration:

location / {
	try_files $uri @proxy;

location /login {
	deny all;
	try_files $uri @proxy;

location @proxy {

	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $remote_addr;
	proxy_set_header X-Forwarded-Proto $scheme;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

When I leave the http_addr in grafana.ini empty, everything works fine. But when I try to bind Grafana to or localhost, it stops working. I get a response from Grafana with curl (“If you’re seeing this Grafana has failed to load its application files”), but nginx tells me that the connection is being refused:

2018/11/07 15:57:56 [error] 1010#1010: *1057 connect() failed (111: Connection refused) while connecting to upstream, client:, server:, request: "GET / HTTP/2.0", upstream: "http://[::1]:8082/", host: ""

Again, this isn’t really a big issue. I just feel like I’m missing something completely obvious that would help me to get a better grasp of the communication between proxy and Grafana or the lack thereof.

edit: Grafana v5.3.2 on Debian Stretch