'External client not connecting with Neo4j database: connection refused on kubernetes
Database is deployed successfully and we can access cypher-shell on the pod terminal. However if a client accessing the database using bolt is getting connection refused error. I believe that database binding to localhost is causing this error. However we coudn't find a way to fix it even after tring all the configurations.
We are connecting using the neo4j python driver to connect to the database.
Can you please provide us information to fix it. Here are logs for the pod:
Active database: graph.db
Directories in use:
home: /var/lib/neo4j
config: /conf
logs: /var/lib/neo4j/logs
plugins: /var/lib/neo4j/plugins
import: NOT SET
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
run: /var/lib/neo4j/run
Starting Neo4j.
2022-03-29 14:37:21.249+0000 WARN Config file [/conf /neo4j.conf] does not exist.
2022-03-29 14:37:21.265+0000 INFO ======== Neo4j 3.3.0 ========
2022-03-29 14:37:21.284+0000 INFO Starting...
2022-03-29 14:37:22.089+0000 INFO Bolt enabled on 127.0.0.1:7687.
2022-03-29 14:37:24.630+0000 INFO Started.
2022-03-29 14:37:25.215+0000 INFO Remote interface available at http://localhost:7474/
neo4j config
apoc.export.file.enabled=true `
`apoc.import.file.enabled=true `
`cypher.forbid_shortestpath_common_nodes=false `
`dbms.connector.bolt.enabled=true `
`dbms.connector.bolt.tls_level=OPTIONAL `
`dbms.connector.http.enabled=true `
`dbms.connector.https.enabled=false `
`dbms.directories.import=/mnt `
`dbms.jvm.additional=-Djdk.tls.ephemeralDHKeySize=2048 `
`dbms.jvm.additional=-Dunsupported.dbms.udc.source=tarball `
`dbms.jvm.additional=-XX:+AlwaysPreTouch `
`dbms.jvm.additional=-XX:+DisableExplicitGC `
`dbms.jvm.additional=-XX:+UseG1GC `
`dbms.logs.query.enabled=true `
`dbms.logs.query.rotation.keep_number=7 `
`dbms.logs.query.rotation.size=20m `
`dbms.security.allow_csv_import_from_file_urls=true `
`dbms.security.auth_enabled=false `
`dbms.security.procedures.unrestricted=algo.*,apoc.* `
`dbms.shell.enabled=true `
`dbms.shell.host=0.0.0.0 `
`dbms.connector.bolt.advertised_address=0.0.0.0:7687 `
`dbms.windows_service_name=neo4jwrapper.java.additional=-Dneo4j.ext.udc.source=docker `
`ha.host.data=neo4j-54b7ff6bdd-td5nt:6001 `
`ha.host.coordination=neo4j-54b7ff6bdd-td5nt:5001 `
`dbms.tx_log.rotation.retention_policy=100M size `
`dbms.memory.pagecache.size=512M `
`dbms.memory.heap.max_size=512M `
`dbms.memory.heap.initial_size=512M `
`dbms.connectors.default_listen_address=0.0.0.0 `
`dbms.connector.https.listen_address=0.0.0.0:7473 `
`dbms.connector.http.listen_address=0.0.0.0:7474 `
`dbms.connector.bolt.listen_address=0.0.0.0:7687 `
`causal_clustering.transaction_listen_address=0.0.0.0:6000 `
`causal_clustering.transaction_advertised_address=neo4j-54b7ff6bdd-td5nt:6000 `
`causal_clustering.raft_listen_address=0.0.0.0:7000 `
`causal_clustering.raft_advertised_address=neo4j-54b7ff6bdd-td5nt:7000 `
`causal_clustering.discovery_listen_address=0.0.0.0:5000 `
`causal_clustering.discovery_advertised_address=neo4j-54b7ff6bdd-td5nt:5000 `
`EDITION=community `
`CONF=/conf `
Solution 1:[1]
I am pretty unsure what setting where enabled and which not. I can only assume that the config given above is not the active config.
The output of the started server contains this line:
...
Bolt enabled on 127.0.0.1:7687
...
That means that your advertised and listen address for Bolt is not properly configured to listen on 0.0.0.0:7687 (or on appropriate IPv6 address) but only 127.0.0.1/localhost.
dbms.connector.bolt.advertised_address=0.0.0.0:7687
dbms.connector.bolt.listen_address=0.0.0.0:7687
should do the job. (At least for 3.5 and later versions, I am unsure about the mentioned 3.3 right now, but think they were there before)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | meistermeier |
