getting dial tcp: i/o timeout when accessing internet from a service inside a container

18,881

I was to solve this error by including Google DNS (8.8.8.8) in my machine's nameservers. I think this error was due to the slow domain resolution process as my machine was getting DNS from DHCP.

I followed these steps:

  1. Set static DNS in /etc/resolvconf/resolv.conf.d/basefile:

    nameserver 8.8.8.8
    nameserver 8.8.4.4

  2. Configure your PC so that it uses user-provided DNS, instead of obtaining it from DHCP. For that, open this file /etc/dhcp/dhclient.conf and add this line:

    supersede domain-name-servers 8.8.8.8, 8.8.4.4;

  3. Restart network manager using:

    sudo service network-manager restart

Share:
18,881
Amit Chahar
Author by

Amit Chahar

Updated on June 15, 2022

Comments

  • Amit Chahar
    Amit Chahar almost 2 years

    I am using PubNub (GO SDK) publish/subscribe service to receive messages but I am not receiving any messages even when I am able to ping google.com from inside the container.

    In the Pubnub logs, every time my program tries to connect to the origin (Pubnub server), I am getting "dial tcp: i/o timeout" error. I guess this is due to the slow internet connection either on the host or in the container.

    What should I do to get around this error?