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:
Temporary failure in name resolutionConnection refusedConnection to bing.com timed out- Other network errors
You can perform the following operations sequentially to troubleshoot the issue:
- Execute
ping 8.8.8.8on the host machine to check if the host can access the public network. - Execute
curl http://bing.comon the host machine to check if the host's DNS is functioning normally. - 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. - 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 | |