I have a weird recurring issue. I'm using Docker to run a Ruby container on Mac OS. The Dockerfile is pretty normal:

FROM ruby:2.7.6-slim

RUN apt-get update -qq && \
  apt-get install -y git libpq-dev libxml2-dev build-essential libcurl4-openssl-dev && \
  apt-get install -y curl gnupg apt-transport-https postgresql-client imagemagick file && \

... irrelevant stuff ...

Shortly after starting the container, my local machine invariably loses its connection to http://deb.debian.org during the apt-get install phase. Subsequent attempts to start the container will net the following error:

#5 30.70 W: Failed to fetch http://deb.debian.org/debian/dists/bullseye/InRelease  Could not connect to deb.debian.org:80 (, connection timed out
#5 30.70 W: Failed to fetch http://deb.debian.org/debian-security/dists/bullseye-security/InRelease  Unable to connect to deb.debian.org:80:
#5 30.70 W: Failed to fetch http://deb.debian.org/debian/dists/bullseye-updates/InRelease  Unable to connect to deb.debian.org:80:

It's having trouble connecting to http://deb.debian.org/*. I can verify this by just attempting $ curl http://deb.debian.org/debian/dists/bullseye/InRelease in either the Docker container, or in my local machine. In both places it just hangs forever. Same if I just try to open that website in a browser.

If I restart my host machine, I regain the ability to connect to deb.debian.org over HTTP temporarily. At least, until I try to restart the Dockerfile.

It feels like a firewall issue, but I don't think it is a firewall issue. Other computers on my LAN are able to run the container from the same Dockerfile without issue. It seems to be localized to just this computer.

I've tried using a VPN, and using my mobile phone data connection. Both fail similarly, so it must be localized to this machine.

Are there any additional troubleshooting steps I can perform to try and determine where I'm losing the connection? I tried a traceroute, and it made it a few hops before similarly getting stuck.

  • Check your routing, table seems you are needing it Aug 30 at 6:51
  • Use ip route, read man ip-route ip.
    – waltinator
    Sep 7 at 3:27
  • Don't you have other computer on the network trying to take the same IP address maybe?
    – pbies
    Sep 10 at 21:11
  • Have you opened another terminal window and tcpdump-ed your internet connection (WiFi or Ethernet) while running docker in a second window. Do you have dump logs if the problem? Is anything in it interesting? Sep 11 at 11:01
  • You say that you regain the ability to ping when you restart, try pinging then and later when it doesn't work. If the IPs are different, you could just edit your /etc/hosts file and put IP that worked with URL there. Not a nice job, but hey if it works... :)
    – pormulsys
    Sep 12 at 12:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.