Skip to content

Network Errors, Connection Resets, Requiring Docker Restart #3448

Open

Description

@micchickenburger
  • I have tried with the latest version of my channel (Stable or Edge)
  • I have uploaded Diagnostics
  • Diagnostics ID: 70614E8F-4B41-4857-9044-8A1A2C1A5FFC/20190108175851

Expected behavior

Networking between my Mac OS host and running docker containers should not sporadically stop working.

Actual behavior

I'm experiencing network errors (connection resets, network errors) between my Mac host and all running docker containers. Restarting the containers does not resolve the problem. I have to restart docker to solve the problem. I've experienced this problem twice today, but had never experienced it before.

Information

  • macOS Version: macOS Mojave 10.14.2

Diagnostic logs

image

Steps to reproduce the behavior

It's hard to reproduce. Connectivity just ceases seemingly randomly, requiring me to restart docker. This is occurring on a fresh docker install as well.

Activity

  1. micchickenburger commented on Jan 8, 2019

    @micchickenburger
    Author

    When the issue occurs, this is the error I receiving trying to run mongo on my host to connect with the monger server in my mongo docker container.

    $ mongo
    MongoDB shell version v4.0.2
    connecting to: mongodb://127.0.0.1:27017
    2019-01-08T12:18:13.494-0600 E QUERY    [js] Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017'  :
    connect@src/mongo/shell/mongo.js:257:13
    @(connect):1:6
    exception: connect failed
    

    This is the issue I experienced trying to create an SQS queue on localstack:localstack running in a container:

    Starting Localstack...
    Started Localstack with hash 8a42a0e43174653894b4e1985d7d835f48b8da6ab46e7ecef57f66edaff4176d
    Creating queue jobs at SQS endpoint http://localhost:4576/queue/jobs
    An error occurred (502) when calling the CreateQueue operation (reached max retries: 4): Bad Gateway
    

    Image versions:

    $ docker image ls
    REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
    localstack/localstack   latest              c583aaf39486        4 days ago          1.02GB
    mongo                   latest              7177e01e8c01        10 days ago         393MB
    
  2. piniondna commented on Jan 8, 2019

    @piniondna

    I am also experiencing this issue. Same exact Docker for Mac version. The docker compose containers will start up fine after a system reboot or docker restart, but the network mapping to the host will stop responding after a (seemingly) random amount of time.
    I can still bash into the containers, and they access each other through curl, so the docker sub-network seems to be fine, but there is no system host mapping. I get timeouts trying to access them from a browser.

    I've allocated 16gb to docker and 6 cpus, so I don't think it's a resource issue. The stack uses roughly 6gb of memory.

  3. lduchesne commented on Jan 8, 2019

    @lduchesne

    I too had this problem and downgrading to Docker Community Edition 18.06.0 seemed to have fixed it. It might be related to #3360

  4. schmurgon commented on Jan 9, 2019

    @schmurgon

    Same problem here on all versions higher than 18.06.1-ce-mac73 (26764). For me, the network connections drop out when using the JVM debugger after about 60 seconds.

  5. onmomo commented on Jan 10, 2019

    @onmomo

    Same Problem here: Diagnostics ID: 2D80AB9C-9218-4705-933D-0B9B7525F15A/20190104105334
    Might be related to #3417

  6. ivester commented on Jan 10, 2019

    @ivester

    Same problem here

  7. retoheusser commented on Jan 10, 2019

    @retoheusser

    I experience this too...

  8. jeff-cook commented on Jan 10, 2019

    @jeff-cook

    I experience this as well. Same version.

    screen shot 2019-01-10 at 3 23 58 pm

    docker version
    Client: Docker Engine - Community
    Version: 18.09.0
    API version: 1.39
    Go version: go1.10.4
    Git commit: 4d60db4
    Built: Wed Nov 7 00:47:43 2018
    OS/Arch: darwin/amd64
    Experimental: false

    Server: Docker Engine - Community
    Engine:
    Version: 18.09.0
    API version: 1.39 (minimum version 1.12)
    Go version: go1.10.4
    Git commit: 4d60db4
    Built: Wed Nov 7 00:55:00 2018
    OS/Arch: linux/amd64
    Experimental: true

  9. jeff-cook commented on Jan 10, 2019

    @jeff-cook

    I have noticed that when it happens the CPU spikes. I have not figured out if the spike is a cause or a symptom.

  10. jeff-cook commented on Jan 11, 2019

    @jeff-cook

    It defiantly seems load based. I was able to make it a day and overnight without network loss. I was only running one small web service. First time in a week I have been able to run longer than an hour or two.

  11. josh-h commented on Jan 11, 2019

    @josh-h

    @jeff-cook I'm not certain it is load related. I experienced similar symptoms with UDP packets failing to be bridged into the container. In each of the several cases the container ran for 24 hours or so and when returning to the office in the morning the networking to the container was dead. During the day the host would have constant use with periods of the CPU being driven hard. So, I suspect it is not load, but some other condition that triggers the bug.

    My environment is a mac server with a static IP assigned, so it is not related to sleep or flaky wifi connections. Reverting to 18.06.1 seems to be a valid workaround, so far.

  12. jeff-cook commented on Jan 11, 2019

    @jeff-cook

    It happened (76297123-260B-45B6-872E-9DE74FB5F950/20190111200619) even after a downgrade to Version 2.0.0.0-mac78 (28905) c404a62c3f

  13. josh-h commented on Jan 16, 2019

    @josh-h

    This issue occurred again, after 2 days of uptime, running Server Version: 18.06.1-ce.

    I've determined that ingress network connections succeed (ie. I see UDP network packets arrive in the container). However, outbound connections from the container fail (ie. ping google.com doesn't receive any responses). Restarting the engine resolved the outbound connection issue.

  14. 51 remaining items

  15. merges commented on Dec 30, 2021

    @merges

    Same problem. Is this being looked at by the maintainers at all?

  16. rfay commented on Dec 30, 2021

    @rfay

    /lifecycle frozen

  17. sageavaa commented on May 31, 2022

    @sageavaa

    I've recently started facing this same issue. I'm on docker 4.8.2 , macos 12.4 Monterey .
    I've tried replacing docker.host.internal to my laptop's public IP but still no luck. Everything will work fine after docker restart and then after few minutes connection timeouts will start. :(
    Does anybody found any workaround this issue?

  18. razorman8669 commented on Jun 25, 2022

    @razorman8669

    seems like the for-win folks have a very similar issue as the for-mac peeps. I used a suggestion from this other thread docker/for-win#8861 and I can confirm that by downgrading docker desktop for mac to version 4.5.0 "fixes" the problem and I no longer have network issues. I tested for several days without any problems. Then upgraded back to the latest version and started getting timeouts and connection failures almost immediately again.

    there must have been something that occurred between 4.5.0 and now that is causing networking issues.

  19. alisterscott commented on Jul 7, 2022

    @alisterscott

    I finally got the fcking working solution:

    Turn on "Experimental Feature" > "Use the new Virtualization framework"
    Edit "/Users/$USER/Library/Group Containers/group.com.docker/settings.json"
    "useVpnkit": false,
    Restart Docker Daemon

    You can thank me later.

    @pich4ya works on Macbook Air M1 - thank you 👍

  20. fabswt commented on Dec 10, 2022

    @fabswt

    The option mentioned in the previous post is now found in the Docker preferences in General under:

    Use Virtualization framework

    Seems to help, it's been 24 hours since I ticked the option and no more issues, while I'd typically lose connectivity 3 to 5 times a day. EDIT: never mind, still losing the connection.

    My issue was is: I'd regularly lose the connection to some APIs from inside Docker. Regularly, my Python Flask app would no longer be able to connect to the OpenAI API (timeout) from Docker, curl from Docker would not be able either (timeout); BUT: curl calls from macOS would still work (so not an issue with the API), as would API calls to Azure from inside the Docker container. Restarting the container did not help. Had to restart Docker every time to restore proper connectivity. Did not know how to diagnose the issue.

  21. fabswt commented on Jan 11, 2023

    @fabswt

    So, doing some local development… In 3 hours of coding, had to restart the Docker app 10 times, because it'd lost connectivity as described in the previous post.

    I love using Docker to aim for dev-prod parity, but at this pace it's getting counter-productive.

  22. fabswt commented on Jan 16, 2023

    @fabswt

    With useVpnkit=false takes forever to start. Tested on 4.15.0 to 4.16.1.

  23. maxgurewitz commented on Feb 3, 2023

    @maxgurewitz

    On macOS Monterey 12.6.2, docker version 20.10.22, docker desktop 4.16.2, and I'm experiencing this issue. Tried setting "useVpnkit": false but docker still hadn't re-started after 15 minutes, so I gave up on that approach.

  24. iancmcc commented on Feb 10, 2023

    @iancmcc

    I'd been disabling vpnkit to get around this issue for months, but as of Ventura 13.2 / Docker Desktop 4.16.2, docker will no longer start with "useVpnkit": false and this issue is as present as ever. Not sure what to do at this point; Docker is effectively useless for any stack that opens a significant number of connections on startup.

  25. iancmcc commented on Feb 15, 2023

    @iancmcc

    Downgrading to Docker Desktop 4.8.2 and reapplying the "useVpnkit": false configuration works around the issue for now.

  26. dimitrovs commented on Jul 4, 2023

    @dimitrovs

    I was able to solve this problem by removing Docker Desktop for Mac and installing:

    brew install docker docker-compose colima
    colima start --cpu 1 --memory 2 --disk 10

    I also had to edit ~/.docker/config.json to remove the credsStore line.
    After that everything is working correctly.

  27. robevansuk commented on Jun 26, 2025

    @robevansuk

    Switching to Orbstack resolved this issue for me. However I wanted to add a few things I tried which may or may not be helpful...

    Running docker compose up with a single postgres db service - worked as expected I could connect to localhost:5432 without issue.
    Running docker compose up with 2 services (or more) - network connectivity issues experienced. 10-20% success rate using the same localhost:5432 connection url as before.

    I deleted containers, volumes, networks between runs using:

    docker rm -f $(docker ps -aq); docker volume rm $(docker volume ls -qf dangling=true); docker network prune -f;
    

    orbstack didn't seem to have the same issue mapping the container across the host network and was 100% reliable in comparison to docker-desktop which is essentially now obsolete for me as a result of its failure to reliably map containers to the relevant host/port so I can connect from the IDE to the database. Other containers didn't seem to have an issue as I was also running PgWeb as well as Postgres

  28. pkit commented on Aug 13, 2025

    @pkit

    Just another 5 cents.
    If using Docker Desktop: pinning it to 1 CPU thread removes all problems (obviously at the expense of being slow asf), so it's a clear multithreading bug.
    When using Colima it mostly works. Why mostly: still get random "connection reset" from time to time, pretty rarely though.
    I suspect it's just OSX problem after all though because why would it be that similar for docker desktop and colima?
    Obviously on my Linux dev machines nothing ever flaked in these tests.

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