Troubleshooting / Code Cannot Access the Internet
A Script cannot access the internet, mostly due to DNS or firewall issues.
Specifically, when a Script executes code such as requests.get('http://bing.com'), the following errors occur:
Temporary failure in name resolutionConnection refusedConnection to bing.com timed out- Other network errors
You can troubleshoot the issue by performing the following steps in order:
- On the host machine, run
ping 8.8.8.8to check whether the host machine can access the internet. - On the host machine, run
curl http://bing.comto check whether the host machine's DNS is working properly. - Run
docker exec -it {DataFlux Func Container ID} sh -c 'exec ping 8.8.8.8'to check whether the container can access the internet. - Run
docker exec -it {DataFlux Func Container ID} sh -c 'exec curl http://bing.com -i'to check whether the container's DNS is working properly.
8.8.8.8 is the address of a common public DNS server
If the installed DataFlux Func image does not include the ping command, you can use curl http://{IP Address} instead
Possible causes and solutions:
| Possible cause | Solution |
|---|---|
| The host cannot access the internet or DNS is not working properly | Check and adjust the operating system network configuration |
| The container cannot access the internet or DNS is not working properly | Check and adjust Docker-related configuration, 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 restart the Docker service:
| JSON | |
|---|---|
1 2 3 4 5 6 | |