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 "http://10.0.0.52:5555/repository/maven-group-all" }
	jcenter()
	mavenCentral()
	maven { url "https://maven.springframework.org/release" }
	maven { url "https://download.java.net/maven/2" }
}

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 ‘http://10.0.0.52:5555/repository/maven-group-all/org/springframework/spring-context/5.3.1/spring-context-5.3.1.pom’.
Could not GET ‘http://10.0.0.52:5555/repository/maven-group-all/org/springframework/spring-context/5.3.1/spring-context-5.3.1.pom’.
Connect to 10.0.0.52:5555 [/10.0.0.52] failed: Connect timed out