non-local API server connection refused when using '-config'
When running toxiproxy server on a remote host with -config and trying to use toxiproxy-cli against it with the --host flag it gets connect: connection refused error.
The content of my config file is
[
{
"name": "registry",
"listen": "[::]:5001",
"upstream": "10.12.80.149:21146",
"enabled": true
}
]
After running with and without the config file, I eventually noticed that when running without, the toxiproxy server log for starting the API server looks like this:
{"level":"info","host":"0.0.0.0","port":"8474","version":"2.5.0","caller":"api.go:119","time":"2023-06-20T19:59:52Z","message":"Starting HTTP server on endpoint 0.0.0.0:8474"}
but when running with config it looks like this
{"level":"info","host":"localhost","port":"8474","version":"2.5.0","caller":"api.go:119","time":"2023-06-20T19:59:52Z","message":"Starting HTTP server on endpoint localhost:8474"}
with "localhost" rather than "0.0.0.0" and since I'm running toxiproxy-cli with --host http://<host_ip>:8474 (i.e. the host is an IP and not localhost) it refuses the connection.
I'm able to work around it by explicitly running the server with -host 0.0.0.0, but find it odd that the listen host would be different depending on if a config is used or not (actually, I suspect the act of creating proxies before the API server starts is what actually impacts it, based on a quick read of the code).
Hi,I have the same issue with docker. As @bjornbyte said, it works when adding -host 0.0.0.0!