Based on the error message, it makes me wonder if localhost:5000 is being resolved as an ipv6 address, which you may not want. You could try changing that to 127.0.0.1:5000
EDIT: In your proxy_pass line, it is possible you are missing part of the URL? Try adding $request_uri so it could be:
Not sure which one is most correct.
Another thing to consider. Your config indicates:
So, localhost:8080 may not be matched.
For testing, you could change this to:
server_name registry.mydomain.com localhost;
Then the localhost:8080 would be matched, as well as your domain. I assume registry.mydomain.com is just an example and you would put your real server FQDN in there.