Skip to content

Troubleshooting / Code Unable to Access External Network

The inability to access the external network within scripts is mostly due to DNS or firewall issues.

Specifically, when a script executes code similar to requests.get('http://bing.com'), the following errors may occur:

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

You can perform the following operations sequentially to troubleshoot the issue:

  1. Execute ping 8.8.8.8 on the host machine to check if the host can access the public network.
  2. Execute curl http://bing.com on the host machine to check if the host's DNS is functioning normally.
  3. Execute docker exec -it {DataFlux Func container ID} sh -c 'exec ping 8.8.8.8' to check if the public network is accessible from within the container.
  4. Execute docker exec -it {DataFlux Func container ID} sh -c 'exec curl http://bing.com -i' to check if DNS is functioning normally within the container.

8.8.8.8 is a commonly used public DNS server address.

If the installed DataFlux Func image does not have the ping command, you can use the curl http://{IP address} command instead.

Possible causes and solutions:

Possible Cause Solution
Host machine cannot access the public network or has abnormal DNS Check and adjust the operating system's network configuration.
Container cannot access the public network or has abnormal DNS Check and adjust Docker-related configurations, and if necessary, check the operating system's network configuration.

Docker DNS Configuration Reference

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

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