Python scripts may face issues when specific requirements don’t meet at runtime.
In this article, We’ll see “Failed to establish a new connection: [Errno -3] Temporary failure in name resolution”. Just by looking at the error message, it seems more like a DNS failure or hostname issue (not propagated globally yet). But it is different in my case. It took me more than an hour just to find out what is the exact issue and troubleshoot it.
After reading all the logs files I came to a conclusion:
The issue is related to the OOM (Out of Memory) or OOD (Out of Disk) of the instance which is killing the process of a python script due to which the “Instance reachability check failed” and I was getting “Failed to establish a new connection: [Errno -3] Temporary failure in name resolution”. After upgrading the server instance, the instance reachability didn’t fail, and now able to run the python script containing API.
You can also increase the swap size of the server instance if upgrading the server isn’t affordable, the performance will be slower when RAM is full. But it won’t fail now.
Also, make sure all the allocated hardware resources aren’t limited to the project. Just log in to another SSH session and run
htop command to see processes.
AWS users can read this: Check failure and unreachability of EC2 Linux instance.
The instance status check failure indicates an issue with the reachability of the instance. This issue occurs due to operating system-level errors such as the following:
Failure to boot the operating system, failure to mount the volumes correctly, and Exhausted CPU and memory, this is all happening in our case. Kernel Panic!
If you are running applications in docker, then allow more space to breathe in by removing unnecessary or unused dockers. Use the following command for this:
sudo docker system prune --all
Make sure you have a backup of the server instance or running applications.
Leave a Reply