IntelliJ Gradle Failed to ping owner of lock for file hash cache
I have been frequently encountering an error with Gradle builds in IntelliJ where Gradle will randomly fail to acquire a Gradle cache lock when running a build. It will also happen when using Gradle CLI commands, resulting in the following error in IntelliJ’s Build window:
> Failed to ping owner of lock for file hash cache (/Users/user/.gradle/caches/7.0.2/fileHashes) (lock id: -55162352352)
This seems to be intermittently caused by an issue in which a duplicate Gradle daemon will be running in the background or IntelliJ has inadvertently launched a second daemon for some unknown reason. The error persists even upon restart of the IDE.
The quickest way I have found to fix this problem is to run the following command from the Terminal window in IntelliJ:
It should now let you run a build without any issues. If you know a better way to solve this, please drop a comment below!