Fixing solr error: “/var/solr/data/core_name/data/index/write.lock”

If you deploy a new core in Solr from a backup, you can get this cryptic error:

core_name: 
org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: 
/var/solr/data/core_name/data/index/write.lock

This means Solr can’t write the file it uses to monitor locks. Most likely this is due to files having the wrong ownership.

Navigate to the path on the machine listed, and do this – you’ll see the correct user information on other files.

ls -al

Then you can run this (my solr user is “solr”)

chown -R solr:solr core_name

And restart solr:

/etc/init.d/solr restart