0

I'm encountering an issue while using the curl -o command to transfer files within a Docker container on macOS. The transfer process is being interrupted, and I receive the following error message: curl: (56) Recv failure: Connection reset by peer.

Here are the specific steps I've taken:

  1. On the host machine, I start a Python server using the command nohup python3 -m http.server > python_server.log &.
  2. Within the locally running Docker container, I attempt to transfer the file using the following command:
    curl -o /tmp/guan-data-1.0-SNAPSHOT.zip http://docker.for.mac.localhost:8000/guan-data-1.0-SNAPSHOT.zip
    

During the file transfer, I consistently encounter the error message mentioned above.

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                              Dload  Upload   Total   Spent    Left  Speed
37  776M   37  290M    0     0   509M      0  0:00:01 --:--:--  0:00:01  516M
curl: (56) Recv failure: Connection reset by peer

However, occasionally, the transfer is successful, seemingly depending on the file size or transfer duration. The Python server's logs show the following output:

::ffff:127.0.0.1 - - [07/Jun/2023 15:06:28] "GET /guan-data-1.0-SNAPSHOT.zip HTTP/1.1" 200 -
----------------------------------------
Exception occurred during processing of request from ('::ffff:127.0.0.1', 59020, 0, 0)
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 683, in process_request_thread
 self.finish_request(request, client_address)
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 360, in finish_request
 self.RequestHandlerClass(request, client_address, self)
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/server.py", line 653, in __init__
 super().__init__(*args, **kwargs)
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 747, in __init__
 self.handle()
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/server.py", line 427, in handle
 self.handle_one_request()
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/server.py", line 415, in handle_one_request
 method()
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/server.py", line 660, in do_GET
 self.copyfile(f, self.wfile)
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/server.py", line 860, in copyfile
 shutil.copyfileobj(source, outputfile)
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 208, in copyfileobj
 fdst_write(buf)
File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 826, in write
 self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
----------------------------------------

I can confirm that there is no problem when using curl -o 127.0.0.1:8000 directly on the host machine.

Can anyone assist me in resolving this issue or provide some insights to troubleshoot it?

Hex.J
  • 1
  • 2
  • Most likely you can't fix that with cUrl. Login into Docker container and read logs. Maybe container is running out of CPU/Memory when processing bigger files, maybe there is other errors. – Justinas Jun 07 '23 at 07:13
  • This issue seems to occur specifically when using curl within a local container to access a local server. Curling other server addresses from within the local container is successful, and curling my own service from other server's Docker containers is also successful. – Hex.J Jun 07 '23 at 08:22
  • Check [this question](https://stackoverflow.com/questions/10285700/curl-error-recv-failure-connection-reset-by-peer-php-curl) – Justinas Jun 07 '23 at 08:24

0 Answers0