VS Code Gradle extension says there is no connection to the Gradle server
No connection to the gradle server. Try restarting the server.Short answer
The Gradle for Java extension talks to a background task server. The message means that server stopped or never started. Use Restart Server first. If it fails again, the JDK used to launch Gradle is probably wrong, so point java.import.gradle.java.home at a JDK your Gradle version supports.
Fix it fast
1Find out which cause you have
Check that the Gradle wrapper runs outside the editor. If it fails in a terminal too, the problem is Gradle or the JDK, not the extension.
./gradlew --version2Match what you see, then jump to its fix
What does the error look like?
No connection to the gradle server. Try restarting the server.
Cause 1 of 2
The task server stopped or failed to start
1Check
The extension README says this message means the task server stopped or failed to start.
# Gradle view in the Explorer sidebar shows the message2Fix
Click Restart Server in the notification, then wait for the Gradle view to reload.
# notification button: Restart Server3Verify
The Gradle view lists the project and its tasks.
# Gradle view in the Explorer sidebarConfirmed by github.com
Cause 2 of 2
Gradle is launched with an unsuitable JDK
1Check
java.import.gradle.java.home is the JDK used to launch Gradle daemons for imports and tasks. It is separate from java.jdt.ls.java.home, which only runs the Java language server.
./gradlew --version2Fix
Set java.import.gradle.java.home in settings.json to a JDK your Gradle version supports (Java 17 needs Gradle 7.3 or newer, Java 21 needs 8.5, Java 25 needs 9.1.0), then restart the server.
{
"java.import.gradle.java.home": "/path/to/jdk-21"
}3Verify
The task list loads without the connection message.
./gradlew --versionConfirmed by github.com
How do I stop it coming back?
- Keep one JDK path in java.import.gradle.java.home that matches your Gradle wrapper.
- Update the extension when you move to a new major Gradle version.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Gradle runs no Cucumber scenarios from my feature files
Feature files exist under src/test but nothing runs
Cucumber runs on the JUnit Platform, so Gradle must call useJUnitPlatform() and have the cucumber-junit-platform-engine on the test classpath.
4 causes, each with a fixBack end
A Gradle build fails on classes that use Lombok annotations
Error: Annotation processors must be explicitly declared now.
Lombok is two things for Gradle: a compile-time library and an annotation processor.
3 causes, each with a fixBack end
Gradle 8 fails on Report destination: switch to outputLocation
What went wrong: 'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'
Gradle 8.0 removed the deprecated destination and enabled properties of the Report type.
2 causes, each with a fixBack end
IntelliJ IDEA compiles with a JDK that does not know Java 17
Invalid source release: 17
The compiler that IntelliJ or Gradle starts is older than Java 17, but the project asks for Java 17 source.
3 causes, each with a fixBack end
A scanner flags jackson-databind: how to upgrade it in Gradle
jackson-databind vulnerability reported by a dependency scanner
Find where the old jackson-databind comes from, then raise it.
3 causes, each with a fix