No connection to Gradle server. Try to restart server

Hi there,

Everything was working fine until just a day ago. Now, I’m receiving the following notification: “No connection to Gradle server. Try to restart server.”

When I press the button, I receive another notification (screenshot attached):
when pressin the button i got other notification


Please note that JetBrains IDEA is working fine at the same time.

Do you have any suggestions?

Thanks for your help!

In my case this is what worked.

PROBLEM:

CURSOR GIVES ERROR: “No connection to gradle server. Try restarting the server.”

HINT TO SOLUTION:

Screen, [Cursor > View > Output > Output {tab} > Tasks {drop-down menu} > Gradle for Java] indicated environtal variable JAVA_HOME was pointing to the wrong path. It was set to the JAVA_HOME setting in Windows. Android Studio had a different setting for JAVA-HOME.

SOLUTION:

  • Set Windows JAVA_HOME setting to the same as Android Studio’s JAVA_HOME setting. Conjecture is that Cursor uses the Windows variable to figure ot where Java is but recognizes that if it is not the same as Android Studio is using, they might be using two different Java instances which could lead to conflicting code and a corrupt Visual Studio project. Actually, I have problems with this conjecture, but I can’t think of anything better yet.

METHOD:

  • GET THE ANDROID STUDIO JAVA-HOME VALUE
    Android Studio > File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle SDK {Drop-down} > {Note the directory path for JAVA-HOME}

  • UPDATE THE WINDOWS ENVIRONTAL VARIABLE JAVA_HOME WITH THE ANDROID VALUE
    Windows > Start > Search for {Control panel} > Syatem and Security > System > Advanced system setting {tab} > Environtal Variables > {In System Variables text box, look for JAVA_HOME, select it and click the Edit button} > {Set the variable value to the same as for JAVA_HOME in Android Studio}

What puzzles me is if this variable mismatch was the cause, why did Cursor work for a few days after installation before giving that error and then no longer work?

I’m having the same issue. On the first Android project I did, it works perfectly, and the Cursor AI editing was very impressive. I then tried to change the project name, and it got confused like I couldn’t believe. So I started a new project, and I get this “Cannot connect to Gradle server” error. I go back to the other project? Still works. Anything else? “Cannot connect”.

The AI also got confused and claimed that Gradle 8.6 was the newest version, not 8.10.2, but it accepted me correcting it. But that didn’t fix the issue.

I’m going to work through the answer above and I’ll report back.

I’m a bit baffled. Tried that, still getting a build error. Moved the Gradle user to the D: drive where it is definitely, definitely writable. Copied the zip file and the extracted zip of Gradle 8.10.2 to it for good measure. Updated the env strings, twice, also adding GRADLE_USER_HOME. Still getting “Gradle: Build error”.

Also, why is the AI now saying it can’t see the files in the explorer? Is that a new issue I’ve created?

I’ve uninstalled it. Hopefully re-installing it will make it work. It was just like the old joke about “How can’t you see the printer? It’s right there on the end of that cable!” as even when I resync’d things, closed and reopened, tweaked and prodded, the AI was still adamant it couldn’t see the file open in the editor in screen next to it.