Debugging neobolt.exceptions.ServiceUnavailable error

Hello, I seem to be running into the following error and can't pinpoint the cause:

neobolt.exceptions.ServiceUnavailable: Failed to read from defunct connection Address(host='localhost', port=7687) (Address(host='127.0.0.1', port=7687))

My general workflow is something like this:

uri = "bolt://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", mypass))
db = driver.session()
with db.begin_transaction() as tx:
    for d in my_data:
        q = get_query(d)
        tx.run(q)
        tx.success = True
driver.close()

The code runs fine for a while, and several nodes and relationships are successfully added to the graph. But then I will randomly get the error pasted above. Is there anything unusual in my code snippet? What might be the cause of the above error?

I am having the same issue, it seems like the connection to the neo4j database get's cancelled after a while. I am looking for a way to keep the connection open or reopen the connection after closure

Hello,

I had the same problem. Looking at Neo4j documentation - Neo4j Documentation gave me a way to change my code.

Hope this helps...

1 Like