The 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. You can refer to this documentation .Troubleshooting Your VPC Setup section to verify your VPC settings. You may also click the Validate VPC Settings button in CodeBuild's console to check your VPC settings.
Another most likely scenario is your codebuild does not have appropriate permission for accessing code which is either in codecommit,git or s3, if you use wizard to create this it will automatically grant appropriate permission to it.
Hope this helps!