Skip to content

Failed connect returns CURLE_OPERATION_TIMEOUT instead of CURLE_COULDNT_CONNECT on Windows Server 2016 #23084

Closed

Description

@aschank

I did this

(Feel free to edit the title)

After updating from libcurl 8.19.0 to 8.22.0 we experienced the following problem in one of our system tests.

What the test does:
We switch of one of our components during the system test (after having already executed some requests) to check whether or retry-handling works correctly.

Prior to the update we got CURLE_COULDNT_CONNECT when trying to execute a request after shutting down the component on localhost (it's a POST request executed via curl_easy_perform()), after the update we get a CURLE_OPERATION_TIMEOUT.

Also the timeout that actually is used is the operation timeout and not the connection timeout.

We re-tried with libcurl 8.21.0 - this worked the same way like 8.19.0, so the change that introduced this new behaviour seems to be introduced in 8.22.0. The unrealeased master version, that I tried (aff6f93... aff6f93) also behaved the same way as 8.22.0.

When running on Windows Professional 11 this seems not to be the case. There the connection timeout and correct error code is used with libcurl 8.22.0. So this seems to be something specific to some and not all windows environments.

I expected the following

CURLE_COULDNT_CONNECT when a connection cannot be made after the connection timout expired (or sooner) - as with libcurl 8.19.0 - and not CURLE_OPERATION_TIMEOUT after the operation timeout expired.

curl/libcurl version

libcurl 8.22.0 (built with vcpkg)

operating system

Microsoft Windows Server 2016 Standard

Activity

  1. icing commented on Sep 24, 2026

    @icing
    Contributor

    Can you produce a trace of such a run? DEBUG_FUNCTION and curl_global_trace("all") would be good.

  2. aschank commented on Sep 24, 2026

    @aschank
    Author

    Thanks for the quick response.

    I have used a debug_function as proposed in https://curl.se/libcurl/c/CURLOPT_DEBUGFUNCTION.html. I appended the output:

    curl-23084_debug_function.zip

    Please let me know, if you need additional info.

  3. jay commented on Sep 24, 2026

    @jay
    Member

    I notice in your log everything says loclahost and not localhost? Example:

    2026-09-24/16:52:42.698 - == Info: [11-0] Issue another request to this URL: 'http://loclahost:8088/my/test/url/path'
    

    When running on Windows Professional 11 this seems not to be the case. There the connection timeout and correct error code is used with libcurl 8.22.0. So this seems to be something specific to some and not all windows environments.

    Can you bisect it? how to git bisect. The instructions there are for an autotools build but the bisect process is the same regardless of build method.

  4. changed the title [-]Windows Server 2016: Operation timeout and error (CURLE_OPERATION_TIMEOUT) is used instead of connection timeout and error (CURLE_COULDNT_CONNECT) when making request to shut down component.[/-] [+]Failed connect returns CURLE_OPERATION_TIMEOUT instead of CURLE_COULDNT_CONNECT on Windows Server 2016[/+] on Sep 24, 2026
  5. aschank commented on Sep 24, 2026

    @aschank
    Author

    well, I „sanitized“ the URL from the output and the replacement seems to have had a typo in it 😄
    I‘m not sure whether I‘ll have the time to do some bisecting tomorrow, but I will try to have a go at it - if not tomorrow then next week.

  6. aschank commented on Sep 25, 2026

    @aschank
    Author

    done bisecting. it tells me abcb534 is the first bad commit

  7. icing commented on Sep 25, 2026

    @icing
    Contributor

    Looks to me as if Windows did fix a networking bug in its product in the last 10 years, but did not backport it. Or maybe a registry setting is affecting this. Hard to say.

    From curl's side, the log show that it opened a socket to localhost 8080 and is waiting for it to become writeable or fail - neither of which happens.

  8. bagder commented on Sep 25, 2026

    @bagder
    Member

    It is quite strange that switching off SYN retries on localhost would have this effect and as mentioned this seems to imply that your outdated Windows version has a bug in there.

    One way to address this would be to figure out the cutoff version: which Windows version range has this bug, and avoid setting this option for that range. But I don't know how we would go about and figure that out...

  9. aschank commented on Sep 25, 2026

    @aschank
    Author

    I could test on Windows Server 2025 (as well as on Windows Pro 11, like I said in the ticket description). The effect is not visible there, so Windows Server 2025 is OK.

  10. bagder commented on Sep 25, 2026

    @bagder
    Member

    The issue is that the flag TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS, which we passed in to completely eliminate the network delay, isn't defined (or checked) on Windows 10 versions prior to RS3 (Redstone 3). The flag was interpreted as TCP_INITIAL_RTO_DEFAULT_MAX_SYN_RETRANSMISSIONS, causing a retry of 255 times, each one taking 500ms. This made each individual connect delay take 128 seconds in total.

    (source)

  11. bagder commented on Sep 25, 2026

    @bagder
    Member

    So maybe something like #23103 ?

  12. jay commented on Sep 25, 2026

    @jay
    Member

    done bisecting. it tells me abcb534 is the first bad commit

    Thanks I can confirm in Windows 8. It would be helpful if you could try #23103 in Windows Server 2016. There is an automated build of curl-for-win so you don't need to build the branch. Go to the PR > 'Checks' tab > curl-for-win sidebar > Artifacts pane at the bottom > curl.exe

    Please show the error output of curl -v http://localhost:12345
    It should be something like this:

    curl: (7) Failed to connect to localhost:12345 after 741 ms: Could not connect to server
    
  13. aschank commented on Sep 25, 2026

    @aschank
    Author

    I can confirm it. On Windows Server 2016:

    curl 8.22.0:

    curl.exe http://localhost:8765/blabla
    curl: (7) Failed to connect to localhost:8765 after 127955 ms: Could not connect to server
    

    The version with the fix:

    curl.exe http://localhost:8765/blabla
    curl: (7) Failed to connect to localhost:8765 after 743 ms: Could not connect to server
    

    Thanks for the quick response 👍

  14. added a commit that references this issue on Sep 25, 2026
    d84e52f
  15. added a commit that references this issue on Sep 26, 2026
    0feb52b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions