Linux executable (.tar)
Before you install Neo4j on Linux from a tarball and run it as a console application or a service, check System Requirements to see if your setup is suitable.
Install Neo4j from a tarball
-
If it is not already installed, get OpenJDK 17 or Oracle Java 17. From version 5.14 onwards, Neo4j also supports JDK 21.
-
Download the latest Neo4j tarball from Neo4j Deployment Center and unpack it:
tar zxf neo4j-enterprise-5.25.1-unix.tar.gz
-
Move the extracted files to your server’s /opt directory and create a symlink to it:
mv neo4j-enterprise-5.25.1 /opt/ ln -s /opt/neo4j-enterprise-5.25.1 /opt/neo4j
-
Create a
neo4j
user and group:groupadd neo4j useradd -g neo4j neo4j -s /bin/bash
-
Give the directory the correct ownership using one of the options:
-
Ubuntu
chown -R neo4j:adm /opt/neo4j-enterprise-5.25.1
-
RedHat
chown -R neo4j /opt/neo4j-enterprise-5.25.1
-
-
From Neo4j 5.4 onwards, you are required to accept either the commercial or the evaluation license agreement before running the Neo4j Enterprise Edition. If you are using Community Edition, you can skip this step.
-
Use one of the following options to accept the commercial license agreement. See the Neo4j licensing page for details on the available agreements.
-
Set the environment variable
NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
. -
Run
<NEO4J_HOME>/bin/neo4j-admin server license --accept-commercial
-
-
Use one of the following options to accept the Neo4j Evaluation Agreement for Neo4j Software.
-
Set the environment variable
NEO4J_ACCEPT_LICENSE_AGREEMENT=eval
. -
Run
<NEO4J_HOME>/bin/neo4j-admin server license --accept-evaluation
.
-
-
-
(Optional) Decouple the data and configuration directories from the binary files by setting the environment variable
NEO4J_CONF
andserver.directories.data
to point to the desired locations. Storing your data and configuration on a separate disk or partition can simplify the upgrade process later. -
Before starting up the database for the first time, it is recommended to use the
set-initial-password
command ofneo4j-admin
to define the password for the native userneo4j
.If the password is not set explicitly using this method, it will be set to the default password
neo4j
. In that case, you will be prompted to change the default password at first login.
For more information, see Set an initial password. -
Start Neo4j:
-
To run Neo4j as a console application, use:
<NEO4J_HOME>/bin/neo4j console
. -
To run Neo4j in a background process, use:
<NEO4J_HOME>/bin/neo4j start
.
-
-
Open http://localhost:7474 in your web browser.
-
Connect using the username
neo4j
with your password or the default passwordneo4j
. You will then be prompted to change the password. -
Stop the server by typing
Ctrl-C
in the console.
Configure Neo4j to start automatically on system boot
You can create a Neo4j service and configure it to start automatically on system boot.
-
Create the file /lib/systemd/system/neo4j.service with the following contents:
[Unit] Description=Neo4j Graph Database After=network-online.target Wants=network-online.target [Service] ExecStart=/opt/neo4j/bin/neo4j console Restart=on-abnormal User=neo4j Group=neo4j Environment="NEO4J_CONF=/opt/neo4j/conf" "NEO4J_HOME=/opt/neo4j" LimitNOFILE=60000 TimeoutSec=120 [Install] WantedBy=multi-user.target
-
Reload systemctl to pick up the new service file:
systemctl daemon-reload
-
Configure Neo4j to start at boot time:
systemctl enable neo4j
-
Before starting up the database for the first time, it is recommended to use the
set-initial-password
command ofneo4j-admin
to define the password for the native userneo4j
.If the password is not set explicitly using this method, it will be set to the default password
neo4j
. In that case, you will be prompted to change the default password at first login.
For more information, see Set an initial password. -
Start Neo4j:
systemctl start neo4j
-
Check the status of the newly created service:
systemctl status neo4j
-
Reboot the system (if desired) to verify that Neo4j restarts on boot:
reboot
For more information on operating the Neo4j system service, see Neo4j system service.
Setting the number of open files
Linux platforms impose an upper limit on the number of concurrently open files per user and session.
To check your limit for the current session, run the command ulimit -n
.
The default value is 1024.
ulimit -n
However, if you experience exceptions on Too many open files
or Could not stat() directory
, you have to increase the limit to 40000 or more, depending on your usage patterns.
This is especially true when many indexes are used, or the server installation sees too many open network connections or sockets.
A quick solution is the command ulimit -n <the-new-limit>
, but it will set a new limit only for the root user and will affect only the current session.
If you want to set the value system-wide, follow the instructions for your platform.
The following steps set the open file descriptor limit to 60000 for the user neo4j under Ubuntu 16.04 LTS, Debian 8, CentOS 7, or later versions.
Running Neo4j as a service
-
Open the neo4j.service file with root privileges.
sudo systemctl edit neo4j.service
-
Append the following to the
[Service]
section, created in Configure Neo4j to start automatically on system boot:[Service] ... LimitNOFILE=60000
Running Neo4j as an interactive user (e.g., for testing purposes)
-
Open the user.conf file with root privileges in a text editor. This example uses Vim:
sudo vi /etc/systemd/user.conf
-
Uncomment and define the value of
DefaultLimitNOFILE
, found in the[Manager]
section.[Manager] ... DefaultLimitNOFILE=60000
-
Open the /etc/security/limits.conf file.
sudo vi /etc/security/limits.conf
-
Define the following values:
neo4j soft nofile 60000 neo4j hard nofile 60000
-
Reload the
systemd
settings.sudo systemctl daemon-reload
-
Reboot your machine.
Uninstall Neo4j
Follow these steps to uninstall Neo4j on Linux:
-
(Optional) Create a backup to avoid losing your data.
-
Stop all Neo4j running services:
--- sudo systemctl stop neo4j sudo systemctl disable neo4j ---
-
Delete NEO4J_HOME and the file /lib/systemd/system/neo4j.service:
--- rm /lib/systemd/system/neo4j.service rm -rf NEO4J_HOME ---