themetalfleece / neogma

Object-Graph-Mapping neo4j framework, Fully-typed with TypeScript, for easy and flexible node and relationship operations
https://themetalfleece.github.io/neogma/
MIT License
117 stars 11 forks source link

Connection refused in Docker Compose network #39

Open JonasHiltl opened 2 years ago

JonasHiltl commented 2 years ago

I have a Node.js application and Neo4j running through docker compose, they are in the same network so I thought I wouldn't encounter any issues. But neogma fails to connect to Neo4j. It works just fine without docker through localhost.

This is my bolt connection string: bolt://neo4j:7687. neo4j is the name of the docker compose service and it just uses the ip address of the docker service.

This is the error message

Neo4jError: Failed to connect to server. Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0. Caused by: connect ECONNREFUSED 192.168.192.4:7687

As you can see in the error message (ECONNREFUSED 192.168.192.4:7687), docker successfully routes to the ip of the Neo4j container by just specifying the container name. So I'm unsure what could cause this connection issue.

This probably is not caused by neogma but rather by the underlying driver.

themetalfleece commented 2 years ago

Yes this shouldn't be related to Neogma, as it just uses neo4j-driver for connection-related stuff. I'll try this on my own at some point. Until then, could you try refering to threads like this, in case you find anything useful?

Also, is there any chance that Neogma tries to connect to Neo4j before it's ready?

JonasHiltl commented 2 years ago

The Node.js docker service depends on neo4j, so it waits on it to start up. This issue is also tracking the same error, but not solved since half a year.