NodeJS error: Neo4jError: Connection acquisition timed out in 60000 ms

The full error message is:
Neo4jError: Connection acquisition timed out in 60000 ms. Pool status: Active conn count = 0, Idle conn count = 0.

I have a mac development machine running the following:

  • Neo4j server community edition v5.13.0 running locally started with the command: $NEO4J_HOME/bin/neo4j start
    Last entries in debug log:
    2024-01-12 20:44:13.605+0000 INFO [o.n.k.i.a.i.IndexingService] [neo4j/5500debc] IndexingService.init: indexes not specifically mentioned above are ONLINE
    2024-01-12 20:44:13.606+0000 INFO [o.n.k.a.DatabaseAvailabilityGuard] [neo4j/5500debc] Requirement Database unavailable makes database neo4j unavailable.
    2024-01-12 20:44:13.606+0000 INFO [o.n.k.a.DatabaseAvailabilityGuard] [neo4j/5500debc] DatabaseId{5500debc[neo4j]} is unavailable.
    2024-01-12 20:44:13.610+0000 INFO [o.n.k.d.Database] [neo4j/5500debc] Starting transaction log [/some_path/neo4j-community-5.13.0/data/transactions/neo4j/neostore.transaction.db.1663] at version=1663
    2024-01-12 20:44:13.611+0000 INFO [o.n.k.d.Database] [neo4j/5500debc] Starting transaction log [/some_path/neo4j-community-5.13.0/data/transactions/neo4j/checkpoint.0] at version=0
    2024-01-12 20:44:13.611+0000 INFO [o.n.k.i.t.l.f.c.CheckpointLogFile] [neo4j/5500debc] Scanning log file with version 0 for checkpoint entries
    2024-01-12 20:44:13.613+0000 INFO [o.n.k.i.a.i.IndexingService] [neo4j/5500debc] IndexingService.start: indexes not specifically mentioned above are ONLINE
    2024-01-12 20:44:13.614+0000 INFO [o.n.k.a.DatabaseAvailabilityGuard] [neo4j/5500debc] Fulfilling of requirement 'Database unavailable' makes database neo4j available.
    2024-01-12 20:44:13.614+0000 INFO [o.n.k.a.DatabaseAvailabilityGuard] [neo4j/5500debc] DatabaseId{5500debc[neo4j]} is ready.
    2024-01-12 20:44:14.414+0000 INFO [o.n.k.a.p.GlobalProcedures] Called db.clearQueryCaches(): Query cache already empty.
    2024-01-12 20:44:14.448+0000 INFO [o.n.b.p.c.c.n.SocketNettyConnector] Bolt enabled on localhost:7687.
    2024-01-12 20:44:14.448+0000 INFO [o.n.b.BoltServer] Bolt server started
    2024-01-12 20:44:14.448+0000 INFO [o.n.s.A.ServerComponentsLifecycleAdapter] Starting web server
    2024-01-12 20:44:14.979+0000 INFO [o.n.s.CommunityNeoWebServer] HTTP enabled on localhost:7474.
    2024-01-12 20:44:14.980+0000 INFO [o.n.s.CommunityNeoWebServer] Remote interface available at http://localhost:7474/
    2024-01-12 20:44:14.980+0000 INFO [o.n.s.A.ServerComponentsLifecycleAdapter] Web server started.
    2024-01-12 20:44:14.982+0000 INFO [o.n.g.f.DatabaseManagementServiceFactory] id: 9781032BBB8B505BADB7C2D469AAD28FB51CBB15C99EBD648EF361A25E48F3A9
    2024-01-12 20:44:14.982+0000 INFO [o.n.g.f.DatabaseManagementServiceFactory] name: system
    2024-01-12 20:44:14.982+0000 INFO [o.n.g.f.DatabaseManagementServiceFactory] creationDate: 2024-01-05T19:04:39.708Z

  • NodeJS server running locally on localhost:3000 with neo4j-driver v. 5.16.0
    const neo4j = require('neo4j-driver');
    const neo4jUri = 'neo4j://localhost:7687';
    const neo4jUser = 'neo4j';
    const neo4jPassword = 'password';
    const driver = neo4j.driver(neo4jUri, neo4j.auth.basic(neo4jUser, neo4jPassword));
    const query = "MATCH (n) RETURN n LIMIT 10;"
    const session = driver.session({ database: 'neo4j', defaultAccessMode: neo4j.session.READ });
    const result = await session.run(query);
    const dataFromNeo4j = result.json();
    session.close();

In the Neo4J browser I have access to the neo4j database and can run queries on it. The neo4j database is rather large, it has 650million nodes and 650million relationships.

When running a query from NodeJS I get this error in index.js:47:34, row: const result = await session.run(query);

TypeError: promise.finally is not a function

at captureStacktrace (/some_path/node_modules/neo4j-driver-core/lib/result.js:620:17)
at new Result (/some_path/node_modules/neo4j-driver-core/lib/result.js:112:23)
at Session._run (/some_path/node_modules/neo4j-driver-core/lib/session.js:215:16)
at Session.run (/some_path/node_modules/neo4j-driver-core/lib/session.js:180:27)
at app.post (/some_path/index.js:47:34)
at Layer.handle [as handle_request] (/some_path/node_modules/express/lib/router/layer.js:95:5)
at next (/some_path/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (/some_path/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (/some_path/node_modules/express/lib/router/layer.js:95:5)
at /some_path/node_modules/express/lib/router/index.js:284:15

(node:26503) UnhandledPromiseRejectionWarning: Neo4jError: Connection acquisition timed out in 60000 ms. Pool status: Active conn count = 0, Idle conn count = 0.
at new Neo4jError (/some_path/node_modules/neo4j-driver-core/lib/error.js:75:16)
at newError (/some_path/node_modules/neo4j-driver-core/lib/error.js:111:12)
at Timeout. (/some_path/node_modules/neo4j-driver-bolt-connection/lib/pool/pool.js:134:69)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
(node:26503) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:26503) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

As I see it, the issue is that I cannot connect to the Neo4J server and get this error: Neo4jError: Connection acquisition timed out in 60000 ms. Pool status: Active conn count = 0, Idle conn count = 0.
I tried connecting using the bolt protocol and I get the same error.

What am I missing in connecting to the Neo4J server?
Thank you for your help.

Found the issue. I was using node v8.16.1 by mistake instead of a more recent version. Wiped node_modules, npm install with node v21.5.0 and now I can connect to the neo4j server.

We are continuing to receive this error:

Neo4jError: Connection acquisition timed out in 60000 ms. Pool status: Active conn count = 0, Idle conn count = 0.

In other posts, I see suggestions that include having a compatible neo4j driver and a current node version.

We are using Aura with a recent clone (5.20-aura) with the most recent neo4j driver (neo4j-driver 5.21.0).

This is happening in production, where in Vercel we have selected the most recent version offered of node (20x).

So, it does not appear to be an issue with the versions of neo4j, the driver or node.

This happens sporadically. It is hard to figure out a pattern for when.

Any help much appreciated.