non-local API server connection refused when using '-config'
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 12.4k
- Forks
- 510
- PR merge metrics
- No merged PRs in 30d
Description
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).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the API server startup path reported as api.go:119 and reproduce the server with and without -config, comparing the logged listen host and remote CLI connection behavior. Done means configuration loading does not unexpectedly restrict the API to localhost, and toxiproxy-cli can connect through the documented non-local host address without requiring an unexplained workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100