Geo: TCP connection refused when using localhost as hostname

GitLab Geo HTTP(S) connectivity ... 
* Can connect to the primary node ... no
  Reason:
  Failed to open TCP connection to localhost:3001 (Connection refused - connect(2) for "::1" port 3001)
  Try fixing it:
  Check if the machine is online and GitLab is running
  Check your firewall rules and make sure this machine can reach the target machine
  Make sure port and protocol are correct: 'http://localhost:3001/', or change it in Admin > Geo Nodes

gdk.yml, config/gitlab.yml and geo_nodes records were using hostname localhost where appropriate, and URLs like http://localhost:3001 or http://localhost:3002.

When I switched everything back to 0.0.0.0, it worked again.

cc @ashmckenzie