The Problem
All the dnf commands fail with the following error:
# dnf repolist Oracle Linux 8 BaseOS Latest (x86_64) 0.0 B/s | 0 B 00:00 Failed to download metadata for repo 'ol8_baseos_latest' Error: Failed to download metadata for repo 'ol8_baseos_latest dnf was not able to refresh the cache as it could not reach the yum server itself, Hence pointing to cache being expired.
# yum clean metadata Cache was expired <<<<<<<<<<<<<< 0 files remove
The Solution
This issue is caused by a network problem or incorrect proxy settings.
1. Append the proxy to the file /etc/dnf/dnf.conf.
http://[proxy-host].[domain].com:[port]
# vi /etc/dnf/dnf.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
http://[proxy-host].[domain].com:[port]
Please substitute the fully qualified domain name, and the port the proxy is using into the proxy setting above.