The following error message indicates that your build doesn't have internet connectivity.
If you are setting up a project with VPC config, please check your VPC settings.
Goto Troubleshooting Your VPC Setup section to verify your vpc settings or you can also click the validate vpc button on the build to validate vpc settings.
Another scenario is your code build doesn’t have the appropriate permission for accessing code.
For that case you all need to use a wizard to create this code, then it automatically allows the permissions to it.