Skip to content

Troubleshooting / Code Unable to Access the Internet

The script cannot access the external network, mostly due to DNS or firewall issues.

Specifically, when executing code similar to requests.get('http://www.baidu.com'), the following errors occur:

  1. Temporary failure in name resolution
  2. Connection refused
  3. Connection to www.baidu.com timed out
  4. Other network errors

You can perform the following operations in sequence to troubleshoot the issue:

  1. Execute ping 114.114.114.114 on the host machine to check if the host can access the public network.
  2. Execute curl http://www.baidu.com on the host machine to check if the host DNS is functioning properly.
  3. Execute docker exec -it {DataFlux Func (Automata) CONTAINERS ID} sh -c 'exec ping 114.114.114.114' to check if the public network can be accessed from within the container.
  4. Execute docker exec -it {DataFlux Func (Automata) CONTAINERS ID} sh -c 'exec curl http://www.baidu.com -i' to check if the DNS inside the container is functioning properly.

114.114.114.114 is the address of a commonly used public DNS server

If the installed DataFlux Func (Automata) image does not have the ping command, you can also use the curl http://{Baidu IP address} command as an alternative.

Possible causes and solutions:

Possible Cause Solution
Host machine cannot access the public network, DNS is abnormal Check and adjust the operating system network configuration
Cannot access the public network from within the container, DNS is abnormal Check and adjust Docker-related configurations, and check the operating system network configuration if necessary

Docker DNS Configuration Reference

Edit the /etc/docker/daemon.json file, add the following content, save it, and then restart the Docker service:

JSON
1
2
3
4
5
6
{
    "dns" : [
        "114.114.114.114",
        "8.8.8.8"
    ]
}