Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

neo4j - python driver, Service unavailable

I am very new to neo4j and I am trying to stablish a connection from python3.6 to neo4j. I have installed the driver and I am just getting started with the first steps:

import requests import os import time import urllib from neo4j.v1 import GraphDatabase, basic_auth

GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "myPass"))

However, already in this step I am getting an error:

driver = GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "myPass"))
Traceback (most recent call last):

  File "<ipython-input-5-9ba197b31f8c>", line 1, in <module>
    driver = GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "myPass"))

  File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/v1/api.py", line 112, in driver
    return driver_class(uri, **config)

  File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/v1/direct.py", line 56, in __init__
    pool.acquire()

  File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/v1/direct.py", line 37, in acquire
    return self.acquire_direct(resolved_addresses[0])

  File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/bolt/connection.py", line 386, in acquire_direct
    connection = self.connector(address)

  File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/v1/direct.py", line 55, in <lambda>
    pool = DirectConnectionPool(lambda a: connect(a, security_plan.ssl_context, **config), self.address)

  File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/bolt/connection.py", line 457, in connect
    raise ServiceUnavailable("Failed to establish connection to {!r}".format(address))

ServiceUnavailable: Failed to establish connection to ('::1', 7687, 0, 0)

Before doing this, I have started neo4j from the Terminal, and the bolt was successfully enabled on localhost:7687.

Any ideas why I might be getting this error?

Thanks a lot in advance

like image 763
cristinik Avatar asked Mar 29 '17 12:03

cristinik


1 Answers

I had the same issue, it seems to be that localhost resolves by default to ipv6, which that driver version cannot handle yet.

So I just changed localhost to: 127.0.0.1 and it worked.

like image 87
Michael Hunger Avatar answered Sep 23 '22 11:09

Michael Hunger