Repositories does not fall back to URLs when internal repo is unavailable

I have an internal nexus repository. When I’m outside the network, I would like to be able to get resources from maven central, etc. So I have the following repositories configuration:

repositories {
	maven { url "" }
	maven { url "" }
	maven { url "" }

Unfortunately, when I am on the public net, the gradle build hangs and times out after about 2 minutes, rather than falling back to the public repos. It fails with the following message and lots of stacktraces. Ideally I would like it to give up and fall back after about 5 seconds. Is there a way to configure that, or am I stuck having to comment out the internal address whenever I am not on the local 10.x.x.x network?

Could not resolve org.springframework:spring-context:5.3.1.
Required by:
project :api > org.springframework.boot:spring-boot-starter:2.3.5.RELEASE > org.springframework.boot:spring-boot:2.3.5.RELEASE
Could not resolve org.springframework:spring-context:5.3.1.
Could not get resource ‘’.
Could not GET ‘’.
Connect to [/] failed: Connect timed out