Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

go

pubnub

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?

like image 361
Amit Chahar Avatar asked Mar 02 '18 00:03

Amit Chahar


1 Answers

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

like image 179
Amit Chahar Avatar answered Oct 27 '22 17:10

Amit Chahar