---
title: "Deploy Neo4j | Open Source Graph Database"
description: "Self-host Neo4j. Graph database with ACID, vector search & GraphRAG"
category: "Storage"
url: https://railway.com/deploy/neo4j-graph-database
---

# Deploy Neo4j | Open Source Graph Database

Self-host Neo4j. Graph database with ACID, vector search & GraphRAG

**[Deploy Neo4j | Open Source Graph Database on Railway](https://railway.com/template/neo4j-graph-database)**

- **Creator:** Heimdall
- **Category:** Storage
- **Total deploys:** 15

## Template content

### Neo4j https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/neo4j.svg

- **Image:** neo4j:5.26-community
- **Public domain:** Yes

## Documentation

![Neo4j logo](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRR_knRhgKcFDYYmmRbUWq4jAUzhBCpoJctiQ&amp;s)

# Deploy and Host Neo4j on Railway

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/deploy/neo4j-graph-database?referralCode=QXdhdr&utm_medium=integration&utm_source=template&utm_campaign=generic)

Deploy Neo4j, the world's leading open-source graph database, on Railway with persistent storage and full Bolt protocol access. Self-host Neo4j on Railway to get native graph storage, ACID transactions, and the Cypher query language running in minutes. This template deploys a single Neo4j Community Edition service with a volume for data persistence, an HTTP domain for Neo4j Browser, and a TCP proxy for Bolt driver connections.

## Getting Started with Neo4j on Railway

After deployment, open the Railway-generated HTTPS URL to access Neo4j Browser — an interactive query editor and graph visualization tool. Log in with username `neo4j` and the password from your `NEO4J_AUTH` environment variable (everything after `neo4j/`). Run your first Cypher query to verify the connection:

```
CREATE (n:Person {name: 'Alice'})-[:KNOWS]-&gt;(m:Person {name: 'Bob'})
RETURN n, m
```

To connect application drivers (Python, Java, JavaScript, Go, .NET), use the Bolt URL from your TCP proxy: `bolt://:`. The APOC plugin is pre-installed for extended procedures and functions.


## About Hosting Neo4j

Neo4j is a native graph database that stores relationships as first-class citizens, making traversals of deeply connected data orders of magnitude faster than SQL joins. Unlike relational databases that rely on expensive join operations, Neo4j's index-free adjacency means every node directly references its neighbors.

Key features:
- **Cypher query language** — declarative, SQL-like, ASCII-art pattern syntax (now part of the GQL/ISO standard)
- **ACID transactions** with full consistency guarantees
- **APOC library** — ~450 procedures for data integration, algorithms, and conversion
- **Vector search** with metadata filters for GenAI/GraphRAG applications
- **Graph Data Science** — 65+ algorithms including PageRank, community detection, and pathfinding
- **Official drivers** for Python, Java, JavaScript, Go, C#/.NET, and community drivers for Ruby, PHP, Rust

## Why Deploy Neo4j on Railway

One-click graph database with zero infrastructure management:

- Persistent volume at `/data` survives redeploys and restarts
- TCP proxy for Bolt protocol enables driver connections from any language
- Neo4j Browser accessible via HTTPS for interactive queries
- APOC plugin pre-installed — no manual JAR management
- Environment variable configuration — no config files to manage

## Common Use Cases for Self-Hosted Neo4j

- **Knowledge graphs and GraphRAG** — connect data from multiple sources for semantic search and LLM context retrieval using Neo4j's built-in vector search and LangChain integration
- **Fraud detection** — uncover hidden fraud rings by traversing shared devices, addresses, and transaction networks in real-time
- **Recommendation engines** — generate personalized suggestions based on purchase history, behavioral patterns, and customer similarity graphs
- **Identity and access management** — model users, roles, assets, and authorization paths as a graph for instant permission traversals

## Dependencies for Neo4j on Railway

- **Neo4j** — `neo4j:5.26-community` (Community Edition, ~359MB, x86_64 + ARM64)

### Environment Variables Reference for Neo4j

| Variable | Description | Required |
|----------|-------------|----------|
| `NEO4J_AUTH` | Initial admin credentials (`neo4j/`) | Yes |
| `NEO4J_server_default__listen__address` | Bind address (`0.0.0.0` for Railway) | Yes |
| `NEO4J_PLUGINS` | Auto-install plugins (`["apoc"]`) | Recommended |
| `NEO4J_server_memory_heap_initial__size` | JVM initial heap size | Optional |
| `NEO4J_server_memory_heap_max__size` | JVM max heap size | Optional |
| `NEO4J_server_memory_pagecache_size` | Page cache for graph data | Optional |
| `NEO4J_server_bolt_advertised__address` | TCP proxy address for Bolt drivers | Recommended |

### Deployment Dependencies

- **Runtime:** Java SE 21 (bundled in Docker image)
- **Docker Hub:** [neo4j](https://hub.docker.com/_/neo4j)
- **GitHub:** [neo4j/neo4j](https://github.com/neo4j/neo4j)
- **Docs:** [neo4j.com/docs/operations-manual](https://neo4j.com/docs/operations-manual/current/)

## Hardware Requirements for Self-Hosting Neo4j

| Resource | Minimum | Recommended |
|----------|---------|-------------|
| CPU | 2 vCPU | 4+ vCPU |
| RAM | 2 GB | 8-16 GB |
| Storage | 10 GB SSD | 50+ GB NVMe SSD |
| Runtime | Java SE 21 (bundled) | Java SE 21 (bundled) |

Docker defaults allocate 512MB each for heap and page cache (~1.5GB total). For production workloads with larger datasets, increase memory settings via the `NEO4J_server_memory_*` environment variables.

## Self-Hosting Neo4j with Docker

Run Neo4j locally with Docker:

```
docker run -d \
  --name neo4j \
  -p 7474:7474 \
  -p 7687:7687 \
  -v neo4j_data:/data \
  -e NEO4J_AUTH=neo4j/your_secure_password \
  -e NEO4J_PLUGINS='["apoc"]' \
  neo4j:5.26-community
```

Or with Docker Compose:

```
services:
  neo4j:
    image: neo4j:5.26-community
    ports:
      - "7474:7474"
      - "7687:7687"
    volumes:
      - neo4j_data:/data
    environment:
      NEO4J_AUTH: neo4j/your_secure_password
      NEO4J_PLUGINS: '["apoc"]'
      NEO4J_server_memory_heap_max__size: 1G
      NEO4J_server_memory_pagecache_size: 1G

volumes:
  neo4j_data:
```

## How Much Does Neo4j Cost to Self-Host?

Neo4j Community Edition is fully open-source under GPL v3 — free forever with no usage limits. Self-hosting on Railway means you only pay for infrastructure (typically $5-20/month depending on usage). Enterprise Edition adds clustering, RBAC, LDAP, and hot backups starting at ~$20,000/year. The managed cloud service (AuraDB) starts at $65/GB/month. For single-instance deployments, Community Edition provides full ACID transactions, Cypher queries, APOC, and basic Graph Data Science.

## Neo4j vs Memgraph

| Feature | Neo4j | Memgraph |
|---------|-------|----------|
| Storage | Disk-based with caching | In-memory first |
| Query language | Cypher (GQL standard) | Cypher-compatible |
| Latency | Best for deep traversals | Sub-millisecond for simple queries |
| License | GPL v3 (Community) | BSL 1.1 |
| Ecosystem | Largest (300K+ developers) | Smaller, growing |
| Best for | Knowledge graphs, analytics | Real-time streaming |

Neo4j's mature ecosystem, extensive documentation, and ISO-standard Cypher make it the safer choice for most graph database use cases.

## FAQ

**What is Neo4j and why self-host it?**
Neo4j is a native graph database that stores and queries highly connected data using the Cypher query language. Self-hosting gives you full control over your data, no per-GB pricing, and the ability to run alongside your existing Railway services with private networking.

**What does this Railway template deploy?**
A single Neo4j Community Edition instance with persistent storage, the APOC plugin, Neo4j Browser (HTTP), and Bolt protocol access via TCP proxy. Everything needed to start building graph-powered applications.

**Why does Neo4j need a TCP proxy on Railway?**
The Bolt protocol (port 7687) is a binary TCP protocol — not HTTP. Railway's standard HTTPS domain proxy only handles HTTP traffic. The TCP proxy provides a direct TCP connection that all Neo4j drivers (Python, Java, JavaScript, etc.) require for database queries.

**How do I install APOC or Graph Data Science plugins in self-hosted Neo4j?**
Set `NEO4J_PLUGINS=["apoc"]` or `NEO4J_PLUGINS=["graph-data-science"]` as an environment variable. The Docker image automatically downloads and configures the plugins at startup — no manual JAR file management needed.

**Can I use Neo4j with LangChain and LLMs for GraphRAG?**
Yes. Neo4j has built-in vector search (since v5.11), an official `neo4j-graphrag-python` package, and native LangChain integration. You can build knowledge graphs from unstructured text and use them for retrieval-augmented generation.

**How do I connect to Neo4j from my application on Railway?**
Use Railway's private networking for services in the same project: `bolt://neo4j.railway.internal:7687`. For external access, use the TCP proxy URL: `bolt://:`. Authenticate with the credentials from `NEO4J_AUTH`.

**How do I back up Neo4j Community Edition on Railway?**
Use `railway shell` to access the container, then run `neo4j-admin database dump neo4j --to-path=/data/backups/`. The database must be stopped first in Community Edition. Download the dump via `railway volume download`.


## Similar templates

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [EasyImg](https://railway.com/deploy/easyimg) — Simple self-hostable Nuxt.js personal image hosting system.

Open this page in a browser: https://railway.com/deploy/neo4j-graph-database
