Could curl add a --retry-connrefused flag? Some users requested this several times over the years and @gnawhleinad provided a patch:
@gnawhleinad provided a patch
When I have some time (this week), I can work on creating a pull request for this change (with tests).
Feel free to submit a pull request for this at any time. Even adding it as an idea to TODO could be a pull request. The option could possibly be made to work like --retry-for "connrefused|timeouts|ufolandings" to avoid having to do specific options for other conditions for which we could offer retries...
The --retry-connrefused has suddenly started failing for us in our Docker builds using 7.52.1-r3, has anything changed?
No...
The --retry-connrefused has suddenly started failing for us in our Docker builds using 7.52.1-r3, has anything changed?
Check that you are using --retry with --retry-connrefused. Check if the error code is ECONNREFUSED, maybe curl is getting a different error code. I don't know of any way to get the OS ERRNO from the tool (maybe we should add that to --write-out?) but you can change this code to print the errno. Also please check the discussion at #1603. We are going to allow more error codes to be considered connrefused. It would be helpful to know which error code you are experiencing for connrefused. Thanks
Thanks for your advice. Perhaps this transcript will provide some more information. I'm using Docker for Mac.
cloudfind@spirit:~
$ docker --version
Docker version 17.06.0-ce, build 02c1d87
cloudfind@spirit:~
$ docker run -ti alpine
/ # apk add -U curl
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ca-certificates (20161130-r2)
(2/4) Installing libssh2 (1.8.0-r1)
(3/4) Installing libcurl (7.54.0-r0)
(4/4) Installing curl (7.54.0-r0)
Executing busybox-1.26.2-r5.trigger
Executing ca-certificates-20161130-r2.trigger
OK: 5 MiB in 15 packages
/ # curl --retry 1 --retry-connrefused http://localhost/
curl: (7) Failed to connect to localhost port 80: Connection refused
/ # curl --retry 1 --retry-connrefused http://127.0.0.1/
Warning: Transient problem: connection refused Will retry in 1 seconds. 1
Warning: retries left.
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
/ # nslookup localhost
nslookup: can't resolve '(null)': Name does not resolve
Name: localhost
Address 1: 127.0.0.1 localhost
Address 2: ::1 localhost
/ #
Does this belong in a different ticket?
Most helpful comment
Thanks for your advice. Perhaps this transcript will provide some more information. I'm using Docker for Mac.
Does this belong in a different ticket?