Railway

Deploy Neo4J

Graph database for storing and querying connected data

Deploy Neo4J

Just deployed

/data

Just deployed

Deploy and Host Neo4j on Railway

Neo4j is a native graph database. It stores nodes and the relationships between them as first-class records, so traversing a connection is a pointer hop rather than a join. That suits anything where the shape of the connections is the data: recommendation engines, fraud rings, identity graphs, and the knowledge graphs behind GraphRAG systems. Queries use Cypher, a pattern language where (:Person)-[:WORKS_ON]->(:Project) means what it looks like. Community Edition is open source under GPL-3.0.

Self-host Neo4j here with a persistent volume, memory tuning that adapts to whatever plan you put it on, and the APOC procedure library preloaded. Two services deploy: Neo4j itself, and a small Gateway built on Caddy that owns the public domain. Neo4j speaks on two ports — 7474 for the query workspace and HTTP Query API, 7687 for Bolt — and a Railway domain maps to one port, so the gateway splits traffic by protocol: WebSocket upgrades reach Bolt, everything else the UI. One HTTPS URL covers both, and a TCP proxy exposes raw Bolt to drivers outside Railway.

Diagram of the Neo4j and Caddy gateway services on Railway

Getting Started with Neo4j on Railway

Open the deployed URL and you land in Neo4j's query workspace, with a Connect to instance dialog already filled in from the server's discovery endpoint. Pick neo4j+s:// in the Protocol dropdown — the page is HTTPS, so only encrypted schemes are offered — leave the connection URL and neo4j username as they are, and paste the password from the BOLT_PASSWORD variable. Once connected, the left panel fills with node labels, relationship types and property keys, which is the fastest confirmation the deployment is healthy.

Try a first query by pasting this Cypher into the editor and pressing run:

CREATE (a:Person {name:'Alice'})-[:WORKS_ON {since:2026}]->(p:Project {name:'Knowledge Graph'}) RETURN a, p

Then run MATCH p=()-[]->() RETURN p to see it drawn as a graph, and CALL apoc.meta.graph() to confirm APOC is loaded. Change the password with ALTER CURRENT USER SET PASSWORD FROM 'old' TO 'new' — the initial one applies only while the credential store is empty, so your change survives later redeploys.

Neo4j graph visualisation of people working on projects Neo4j Cypher query results shown as a table APOC schema graph of Person and Project node labels

About Hosting Neo4j

Self-hosting Neo4j makes sense when the graph holds data you would rather keep off a managed cloud, when you want it beside the app querying it, or when an instance priced by memory footprint stops paying for itself.

  • Cypher — a declarative pattern-matching query language, now standardised as GQL
  • Index-free adjacency — traversal cost does not grow with database size
  • ACID transactions — full guarantees, not eventual consistency
  • APOC — 450+ procedures for algorithms, import, refactoring and schema introspection
  • HTTP Query API — run Cypher over HTTPS from any language, no driver
  • Drivers — Python, JavaScript, Java, .NET and Go, plus LangChain and LlamaIndex

Neo4j is the database: store, transaction logs and credentials live on the volume at /data, and it listens on 7474 and 7687 inside the private network only. Gateway is the Caddy proxy holding the public domain, and it pins the forwarded host and protocol headers so the addresses Neo4j advertises cannot be spoofed.

Why Deploy Neo4j on Railway

Railway removes the setup work self-hosting a graph database involves:

  • Persistent volume attached and mounted before first boot
  • Heap and page cache sized from the container's real limits
  • HTTPS and certificates handled at the edge
  • Private networking, so your app reaches Bolt without touching the internet
  • Redeploys that leave the volume intact

Common Use Cases

  • GraphRAG and knowledge graphs — store entities pulled from documents, then let an LLM traverse them for grounded answers
  • Recommendations — "customers who bought this also bought" as a two-hop traversal, not a nightly batch job
  • Fraud analysis — surface shared devices, addresses or accounts linking unrelated-looking users
  • Dependency mapping — model microservices or supply chains and query what breaks when a node fails

Dependencies for Neo4j

  • neo4j:2026 — Neo4j Community Edition, the official Docker Hub image, on the 2026 release line
  • caddy:2-alpine — the reverse proxy fronting both Neo4j ports on one domain
  • One Railway volume mounted at /data

No external database is needed, and APOC Core ships inside the image, so nothing downloads at boot.

Environment Variables Reference

VariableServicePurpose
BOLT_PASSWORDNeo4jPassword for the neo4j user; the one value to keep
NEO4J_AUTHNeo4jneo4j/; applied only while the credential store is empty
NEO4J_PLUGINSNeo4j["apoc"] loads the bundled APOC Core library
NEO4J_server_bolt_advertised__addressNeo4jBolt address the discovery endpoint hands clients
BOLT_URLNeo4jPrivate connection string for other services
QUERY_API_URLNeo4jHTTPS endpoint for the Cypher Query API
NEO4J_HOSTGatewayPrivate hostname of the Neo4j service

Anything prefixed NEO4J_ goes straight into neo4j.conf, and an unknown setting stops the server starting — use it only for real settings from the operations manual.

Deployment Dependencies

Hardware Requirements for Self-Hosting Neo4j

ResourceMinimumRecommended
CPU2 vCPU4–8 vCPU
RAM2 GB8 GB or more
Storage10 GB volume20 GB+ SSD, sized to your graph

Neo4j keeps a page cache of the store files plus a JVM heap for queries. This template derives both from the container's limit — roughly 35% heap, 30% page cache — so an 8 GB instance gets ~2.6 GB heap and ~2.3 GB page cache, retuned whenever you resize.

Self-Hosting Neo4j with Docker

The local equivalent is one Docker command, which starts Neo4j with a persistent volume and APOC enabled:

docker run -d --name neo4j \
  -p 7474:7474 -p 7687:7687 \
  -v neo4j-data:/data \
  -e NEO4J_AUTH=neo4j/your-strong-password \
  -e NEO4J_PLUGINS='["apoc"]' \
  neo4j:2026

You can then query it over HTTP with no driver installed, using curl against the Cypher Query API:

curl -u neo4j:your-strong-password \
  -H 'Content-Type: application/json' \
  -d '{"statement":"MATCH (n) RETURN count(n) AS nodes"}' \
  http://localhost:7474/db/neo4j/query/v2

How Much Does Neo4j Cost to Self-Host?

Neo4j Community Edition is free and open source under GPL-3.0, with no per-core licence, seat count or feature gate on the graph engine. You pay only for infrastructure — on Railway, usage-based compute plus the volume. Managed AuraDB starts around $65 per month and scales with memory, and Enterprise Edition is licensed per core. Enterprise adds clustering, role-based access control and online backup; Community gives you the full engine, Cypher and APOC on one instance.

FAQ

What is Neo4j? An open-source native graph database that stores data as nodes and relationships and queries it with Cypher, now standardised as GQL. It is the most widely deployed property-graph database and the usual starting point for GraphRAG.

What does this Railway template deploy? Neo4j Community Edition on a persistent volume, plus a Caddy gateway serving the query workspace, the HTTP Query API and Bolt-over-WebSocket on one HTTPS domain. A TCP proxy exposes raw Bolt to outside drivers.

Why is there a gateway service instead of just Neo4j? Neo4j listens on two ports and a Railway domain maps to one. The gateway routes WebSocket upgrades to Bolt on 7687 and everything else to the UI and Query API on 7474, so one URL covers both.

How do I connect my application to self-hosted Neo4j? Inside the same project use bolt://neo4j.railway.internal:7687 over private networking — reference ${{Neo4j.BOLT_URL}} from your app. From outside, use the TCP proxy address with the bolt:// scheme, or the HTTPS Query API. Prefer bolt:// over neo4j://: routing is a clustering feature and Community Edition is single-instance.

Does this template include APOC, and can I add Graph Data Science? APOC Core is loaded, because it ships inside the official image. To add more, extend NEO4J_PLUGINS["apoc","graph-data-science"] — but those download at container start, lengthening every deploy.

Will my data survive a redeploy? Yes — everything lives on the volume at /data, reattached to each new container, including a password changed through Cypher.

How do I back up a self-hosted Neo4j database? Community Edition has no online backup, so use Railway's volume backups for point-in-time copies and neo4j-admin database dump against a stopped database for a portable archive. apoc.export.cypher.all is a good logical export for smaller graphs.


Template Content

More templates in this category

View Template
smoothmq
A drop-in replacement for AWS SQS

poundifdef
7
View Template
Kafka UI
Kafbat UI — Open-source web UI to monitor and manage Apache Kafka clusters

codestorm
0
View Template
Hatchet Lite
Hatchet Lite with postgres

prncd
1