Skip to content

Troubleshooting / Unable to Access the Internet in Code

When the code cannot access the internet within the script, it is mostly due to DNS or firewall issues.

The specific manifestations are as follows when executing code similar to requests.get('http://bing.com'):

  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 internet.
  2. Execute curl http://bing.com on the host machine to check if the host's DNS is functioning properly.
  3. Execute docker exec -it {DataFlux Func container ID} sh -c 'exec ping 8.8.8.8' to check if the container can access the public internet.
  4. Execute docker exec -it {DataFlux Func container ID} sh -c 'exec curl http://bing.com -i' to check if the DNS within the container is functioning properly.

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 curl http://{IP address} as an alternative.

Possible causes and solutions:

Possible Cause Solution
Host machine cannot access the public internet, DNS is not functioning Check and adjust the operating system network configuration.
Container cannot access the public internet, DNS is not functioning Check and adjust Docker-related configurations, and if necessary, check the operating system network configuration.

Docker DNS Configuration Guide

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"
    ]
}