Are you connected to internet ? Do you have an internet proxy you need to configure to pass through to access outside website ?
This error usually happens when cran website can’t be reached from the calling environment.
the problem is solved usin CRAN mirror
just used the command
chooseCRANmirror()
and select different mirror then install again the packages.
thanks for your response.