curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: curl: (23) Failed writing body (0 != 16383)

From: Jim B. via curl-users <>
Date: Fri, 1 Jan 2021 03:44:27 +0100

On 1/1/2021 12:55 AM, Ray Satiro via curl-users wrote:
> On 12/31/2020 9:57 AM, Hongyi Zhao via curl-users wrote:
>> $ curl -xhttp://  -fsSL
>> | grep -m1 -Po '\w+\.pub'
>> curl: (23) Failed writing body (0 != 16383)
>> I really want curl to quit gracefully once the first match happened.
>> Why it gives the error shown above? How to achieve my purpose?
> My guess is broken pipe because you passed -m1 so grep will exit after
> the first matching line and then curl can't write the rest of the
> body. curl may or may not exit with an error in that case. Since you
> used -S [1] curl will output the error. message. However it's possible
> even if you don't use -S with -s curl may still show you a failed body
> message because this is an unusual case. I will bring that up for
> discussion in the project issues.
> Further, whether you actually get an error code from curl depends on
> whether you're using shell pipefail. And the reason you see the same
> match twice is because grep works matching by line but since you used
> regex and -o it's showing each match from that first matching line.
> To fix the regexp I think you could do '^.*?\K\w+\.pub' but that's not
> going to suppress the error message. You could redirect stderr
> /dev/null or write the output to a temporary file so that the full
> output is written and an error doesn't occur and then grep from that.
> There are probably better ways too, maybe others will have some ideas.
> [1]:

Hey there,

I was dealing with a similar issue only hours ago. When I read this I
though I had a déjà vu.

Google revealed lots of tips on how to prevent it and what the causes
might be. Just try "curl failed writing body". The first hit will be which alone might contain enough causes and remedies.

In my case the output file I was trying to write to had the wrong ownership.

Happy New Year.

Received on 2021-01-01