Unable to run Elasticsearch

I tried to migrate from CE to PRO and wanted to enable Elasticsearch. However the container runs into an error and restarts every other minute.

Error message inside the container is:

{"@timestamp":"2026-06-15T06:34:13.756Z", "log.level":"ERROR", "message":"fatal exception while booting Elasticsearch", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.bootstrap.Elasticsearch","elasticsearch.node.name":"3b327de19128","elasticsearch.cluster.name":"docker-cluster","error.type":"java.lang.IllegalStateException","error.message":"failed to obtain node locks, tried [/usr/share/elasticsearch/data]; maybe these locations are not writable or multiple nodes were started on the same data path?","error.stack_trace":"java.lang.IllegalStateException: failed to obtain node locks, tried [/usr/share/elasticsearch/data]; maybe these locations are not writable or multiple nodes were started on the same data path?\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:293)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.node.NodeConstruction.validateSettings(NodeConstruction.java:513)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.node.NodeConstruction.prepareConstruction(NodeConstruction.java:260)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.node.Node.<init>(Node.java:192)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.bootstrap.Elasticsearch$2.<init>(Elasticsearch.java:242)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.bootstrap.Elasticsearch.initPhase3(Elasticsearch.java:242)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:76)\nCaused by: java.io.IOException: failed to obtain lock on /usr/share/elasticsearch/data\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:238)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:206)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:285)\n\t... 6 more\nCaused by: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/data/node.lock\n\tat java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)\n\tat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)\n\tat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)\n\tat java.base/sun.nio.fs.UnixPath.toRealPath(UnixPath.java:886)\n\tat org.apache.lucene.core@9.11.1/org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:94)\n\tat org.apache.lucene.core@9.11.1/org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:43)\n\tat org.apache.lucene.core@9.11.1/org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:44)\n\tat org.elasticsearch.server@8.15.0/org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:231)\n\t... 8 more\n\tSuppressed: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/node.lock\n\t\tat java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)\n\t\tat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)\n\t\tat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)\n\t\tat java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:261)\n\t\tat java.base/java.nio.file.Files.newByteChannel(Files.java:379)\n\t\tat java.base/java.nio.file.Files.createFile(Files.java:657)\n\t\tat org.apache.lucene.core@9.11.1/org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:84)\n\t\t... 11 more\n"}

The volume is mounted and /opt/seafile-elasticsearch/data is actually created.

Any idea?

The error “failed to obtain node locks” combined with an AccessDeniedException usually indicates that the Elasticsearch process inside the container does not have the necessary permissions to write to the data directory on your host machine.

According to the Seafile Admin Manual, you need to ensure the Elasticsearch data directory has the correct permissions. You can fix this by running the following commands on your host:

mkdir -p /opt/seafile-elasticsearch/data
chmod 777 -R /opt/seafile-elasticsearch/data

Alternatively, some users have resolved this by changing the ownership of the directory to UID 1000, which is the default user for the Elasticsearch container:

chown -R 1000:1000 /opt/seafile-elasticsearch/data

After applying the permission changes, restart your containers:

docker compose down
docker compose up -d
1 Like

Thank you @daniel.pan ! :heart:

That was it. I only focused on the migration documentation (Migration from Seafile Community - Seafile Admin Manual) and this information was not there.

Tested it and after a couple of minutes seems to work, the indices are slowly building.

However noticed, that “content search” does not seem to work on Office Files (docx and odt) but works in Wiki. Is this correct?

Content search for Office and PDF files is disabled by default to save system resources. To enable it, you need to modify your configuration:

  1. Edit seafevents.conf (usually located in your Seafile configuration directory) and set index_office_pdf to true under the [INDEX FILES] section:

    [INDEX FILES]
    enabled = true
    # ... other settings ...
    index_office_pdf = true
    

    Note: The default file size limit for indexing is 10MB. You can adjust this with office_file_size_limit = 20 if needed.

  2. Restart the Seafile server.

  3. Rebuild the search index manually for the changes to take effect on existing files:

    docker exec -it seafile bash
    cd /opt/seafile/seafile-server-latest
    ./pro/pro.py search --clear
    ./pro/pro.py search --update
    

For more details, you can refer to the Advanced File Search configuration in the admin manual.

1 Like