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

  1. If it is not already installed, get OpenJDK 17 or Oracle Java 17.

  2. Download the latest Neo4j tarball from Neo4j Deployment Center and unpack it:

    tar zxf neo4j-enterprise-5.19.0-unix.tar.gz
  3. Move the extracted files to your server’s /opt directory and create a symlink to it:

    mv neo4j-enterprise-5.19.0 /opt/
    ln -s /opt/neo4j-enterprise-5.19.0 /opt/neo4j
  4. Create a neo4j user and group:

    groupadd neo4j
    useradd -g neo4j neo4j -s /bin/bash
  5. Give the directory the correct ownership using one of the options:

    • Ubuntu

      chown -R neo4j:adm /opt/neo4j-enterprise-5.19.0
    • RedHat

      chown -R neo4j /opt/neo4j-enterprise-5.19.0
  6. 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.

  7. (Optional) Decouple the data and configuration directories from the binary files by setting the environment variable NEO4J_CONF and server.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.

  8. 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.

  9. Open http://localhost:7474 in your web browser.

  10. Connect using the username neo4j with the default password neo4j. You will then be prompted to change the password.

  11. 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.

  1. 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
  2. Reload systemctl to pick up the new service file and configure Neo4j to start at boot time:

    systemctl enable neo4j
  3. Start Neo4j:

    systemctl start neo4j
  4. Check the status of the newly created service:

    systemctl status neo4j
  5. 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

  1. Open the neo4j.service file with root privileges.

    sudo systemctl edit neo4j.service
  2. 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)

  1. Open the user.conf file with root privileges in a text editor. This example uses Vim:

    sudo vi /etc/systemd/user.conf
  2. Uncomment and define the value of DefaultLimitNOFILE, found in the [Manager] section.

    [Manager]
    ...
    DefaultLimitNOFILE=60000
  3. Open the /etc/security/limits.conf file.

    sudo vi /etc/security/limits.conf
  4. Define the following values:

    neo4j	soft	nofile	60000
    neo4j	hard	nofile	60000
  5. Reload the systemd settings.

    sudo systemctl daemon-reload
  6. Reboot your machine.

Uninstall Neo4j

Follow these steps to uninstall Neo4j on Linux:

  1. (Optional) Create a backup to avoid losing your data.

  2. Stop all Neo4j running services:

    ---
    sudo systemctl stop neo4j
    sudo systemctl disable neo4j
    ---
  3. Delete NEO4J_HOME and the file /lib/systemd/system/neo4j.service:

    ---
    rm /lib/systemd/system/neo4j.service
    rm -rf NEO4J_HOME
    ---