Caused by: java.nio.file.AccessDeniedException: /var/lib/neo4j/data/databases/corpus/neostore

We installed the latest version of the enterprise version. We loaded a graph database from dumb using this command: sudo neo4j-admin load --from=/path/to/database.dump --database=neo4j --force. After starting neo4j service and starting database, the database itself is not starting. In the debug.log we're getting this error messages: Hastebin: Send and Save Text or Code Snippets for Free | Toptal®

ubuntu version: 18.04.5
neo4j: 4.2.1 (latest stable) enterprise

https://neo4j.com/docs/operations-manual/current/configuration/file-locations/#file-locations-permissions describes the expected directory/file permissions. Does your environment match said requirements

1 Like

We checked the permissions. It didn't help. We also created a new user with full permission and created a new database, which also ended in the same error like above.

What does these commands show?

ls -l /var/lib/neo4j/data/databases/corpus/neostore

and also these?

ls -l /var/lib/neo4j/data/databases/corpus/

ls -lR /var/lib/neo4j/data/databases/corpus/neostore

And from the terminal that you start the DB, can you do touch DIRECTORY/tesfile on the directories above?

It seems to me like a simple file permissions error that needs to be corrected.

Here's the result: Hastebin: Send and Save Text or Code Snippets for Free | Toptal®

so the files are owned by root. Is Neo4j running as root?

What does

ps -eaf | grep java

return? Are you starting Neo4j as user root?

1 Like

Yes, we are starting and running as root.

Result of ps -eaf | grep java

ubuntu   15979 15966  0 08:06 pts/0    00:00:00 grep --color=auto java
neo4j    26120     1  0 Dec28 ?        00:06:31 /usr/bin/java -cp /var/lib/neo4j/plugins:/etc/neo4j:/usr/share/neo4j/lib/*:/var/lib/neo4j/plugins/* -XX:+UseG1GC -XX:-OmitStackTraceInFastThrow -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+TrustFinalNonStaticFields -XX:+DisableExplicitGC -XX:MaxInlineLevel=15 -XX:-UseBiasedLocking -Djdk.nio.maxCachedBufferSize=262144 -Dio.netty.tryReflectionSetAccessible=true -Djdk.tls.ephemeralDHKeySize=2048 -Djdk.tls.rejectClientInitiatedRenegotiation=true -XX:FlightRecorderOptions=stackdepth=256 -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -Dlog4j2.disable.jmx=true -Dfile.encoding=UTF-8 com.neo4j.server.enterprise.EnterpriseEntryPoint --home-dir=/var/lib/neo4j --config-dir=/etc/neo4j
1 Like

I could be entirely mistaken but from your output of ps -eaf | grep java the first column is the user that started the process and in this case it is neo4j.
As a test locally an on a Ubuntu server and as logged in as neo4j I ran

neo4j@neo4j-lg:~/single/instance1/neo4j-enterprise-4.1.3/bin$ ./neo4j start
Directories in use:
  home:         /home/neo4j/single/instance1/neo4j-enterprise-4.1.3
  config:       /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/conf
  logs:         /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/logs
  plugins:      /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/plugins
  import:       /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/import
  data:         /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/data
  certificates: /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/certificates
  run:          /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/run
Starting Neo4j.

and my output is more or less the same as yours, i.e. the first column is neo4j

neo4j@neo4j-lg:~/single/instance1/neo4j-enterprise-4.1.3/bin$ ps -eaf | grep java
neo4j     3660     1 82 12:45 pts/0    00:00:05 /usr/bin/java -cp /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/plugins:/home/neo4j/single/instance1/neo4j-enterprise-4.1.3/conf:/home/neo4j/single/instance1/neo4j-enterprise-4.1.3/lib/*:/home/neo4j/single/instance1/neo4j-enterprise-4.1.3/plugins/* -XX:+UseG1GC -XX:-OmitStackTraceInFastThrow -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+TrustFinalNonStaticFields -XX:+DisableExplicitGC -XX:MaxInlineLevel=15 -Djdk.nio.maxCachedBufferSize=262144 -Dio.netty.tryReflectionSetAccessible=true -Djdk.tls.ephemeralDHKeySize=2048 -Djdk.tls.rejectClientInitiatedRenegotiation=true -XX:FlightRecorderOptions=stackdepth=256 -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -Dfile.encoding=UTF-8 com.neo4j.server.enterprise.EnterpriseEntryPoint --home-dir=/home/neo4j/single/instance1/neo4j-enterprise-4.1.3 --config-dir=/home/neo4j/single/instance1/neo4j-enterprise-4.1.3/conf

however if I stop and restart but under root and thus

 sudo ./neo4j start
Directories in use:
  home:         /home/neo4j/single/instance1/neo4j-enterprise-4.1.3
  config:       /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/conf
  logs:         /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/logs
  plugins:      /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/plugins
  import:       /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/import
  data:         /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/data
  certificates: /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/certificates
  run:          /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/run
Starting Neo4j.

then my output reports

 ps -eaf | grep java
root      4031     1 77 12:45 pts/0    00:00:03 /usr/bin/java -cp /home/neo4j/single/instance1/neo4j-enterprise-4.1.3/plugins:/home/neo4j/single/instance1/neo4j-enterprise-4.1.3/conf:/home/neo4j/single/instance1/neo4j-enterprise-4.1.3/lib/*:/home/neo4j/single/instance1/neo4j-enterprise-4.1.3/plugins/* -XX:+UseG1GC -XX:-OmitStackTraceInFastThrow -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+TrustFinalNonStaticFields -XX:+DisableExplicitGC -XX:MaxInlineLevel=15 -Djdk.nio.maxCachedBufferSize=262144 -Dio.netty.tryReflectionSetAccessible=true -Djdk.tls.ephemeralDHKeySize=2048 -Djdk.tls.rejectClientInitiatedRenegotiation=true -XX:FlightRecorderOptions=stackdepth=256 -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -Dfile.encoding=UTF-8 com.neo4j.server.enterprise.EnterpriseEntryPoint --home-dir=/home/neo4j/single/instance1/neo4j-enterprise-4.1.3 --config-dir=/home/neo4j/single/instance1/neo4j-enterprise-4.1.3/conf

and thus the 1st column reports root which would indicate the java process was started by root.

As you files under data/ are owned by root:root but your ps -eaf | grep java reports a 1st column of neo4j I would expect that java is running as neo4j. So I'm not convinced

Yes, we are starting and running as root.

How was Neo4j installed? tar file? debian install? rpm ??? ????

Thank you. This helped: sudo ./neo4j start.

But why has our ubuntu user no access, although he has sudo permissions.

We installed from this website: https://debian.neo4j.com

You may not understand this...

sudo is a safety mechanism. Having sudo privileges means you can do potentially dangerous things (by having root permission), but only when prefixing a unix command with sudo.

It looks to me like you install neo4j but didn't give other users write permission to the necessary neo4j files.

When you run sudo ./neo4j start you're running neo4j as root. This is potentially dangerous thing to do, as neo4j could by accident write, delete, or read files that it shouldn't.

I suspect you need to figure out how to properly install neo4j. I'm not sure how to do that with debian. Sorry.

1 Like

Similar error. neo4j java.lang.RuntimeException: java.nio.file.AccessDeniedException: /var/lib/neo4j/data/dbms[...]auth.ini.tmp
Luckily solved. In the instructions on how to set up your server, they mention that you can set-initial-password . But I forgot i have to be a sudo user. So across all the tutorial I had to do a sudo. My java was 17 so It was ok. Many thanks for this great documentation!