It's more likely that you may see "Temporary failure in name resolution" or "curl: (6) Could not resolve host:" in terminal.
Introduction
If you are using an Ubuntu server and have encountered the "Temporary failure in name resolution" or "curl: (6) Could not resolve host:" errors or noticed that your server is showing offline in panels like RunCloud or anyother services, there are a few steps you can take to resolve these issues.
- Check your network connection
First, make sure that your server is properly connected to the internet. This can be done by pinging a known website, such as Google, to see if the server is able to reach it. If the ping fails, then there may be an issue with your network connection.
For example, we can run below command.
ping google.com
or
curl ipinfo.io
If you noticed it's producing below errors then we can conclude it's a DNS issue.
ping: google.com: Temporary failure in name resolution
curl: (6) Could not resolve host: ipinfo.io
- Check your DNS settings
The next step is to check your DNS settings. Make sure that the DNS servers listed in your /etc/resolv.conf file are correct and reachable. If they are not, you may need to update them or add additional DNS servers. You can use the nslookup command to test your DNS configuration.
The first step is login to your server via SSH.
Go to /etc/ location using the below command.
cd /etc
Check if the resolv.conf file is symlink or not. If it's a symlink then it's most likely to be created from /var/run/systemd/resolve/stub-resolv.conf or /var/run/systemd/resolve/resolv.conf
You can confirm it by using running the below command from /etc location.
ls -la /etc/resolv.conf
Once confirmed the file, we can just edit the main file as below(if it's symlink from stub-resolv.conf)
vi /var/run/systemd/resolve/stub-resolv.conf
Now, please replace 'nameserver' value, like below
nameserver 8.8.8.8
Save the file and it should be enough. Some may require an interface restart Refer next next step.
- Check for any firewall rules that may be blocking DNS requests
If your DNS settings are correct and you are still experiencing issues, then it is possible that a firewall rule is blocking DNS requests. Check your firewall rules and make sure that they are allowing DNS requests to pass through.
- Restart the networking service
If all else fails, try restarting the networking service on your server. This can be done by running the following command:
ifconfig eth0 down && ifconfig eth0 up
Assuming eth0 is your interface. This will restart the networking service and may resolve the "Temporary failure in name resolution" and "curl: (6) Could not resolve host:" errors.
Conclusion
In summary, if you are experiencing "Temporary failure in name resolution" or "curl: (6) Could not resolve host:" errors on your Ubuntu server, make sure to check your network connection, DNS settings, firewall rules, and try restarting the networking service if necessary. These steps should help resolve these errors and get your server back up and running smoothly.
Comments
Post a Comment