3

I'm unable to connect to Neo4j using neo4j-python-driver version 5.3.0. Requirement is using Neo4j python driver to query NEO4J DB using cypher queries. It gives the error failed to connect to server even when the database is up and running and i can able to login and use through NEO4J Desktop. Getting below error

neo4j.exceptions.ServiceUnavailable: Couldn't connect to <URI>:7687 (resolved to ()):
[SSLCertVerificationError] Connection Failed. Please ensure that your database is listening on the correct host and port and that you have enabled encryption if required. Note that the default encryption setting has changed in Neo4j 4.0. See the docs for more information. Failed to establish encrypted connection. (code 1: Operation not permitted)

Note : URI hided in the above error.

I have added the exception to Ignores certificate verification issue, but it won't solve the issue.

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Appreciate your help to resolve the issue.

i'm connecting via below snippet

from neo4j import GraphDatabase
import urllib3

#Ignores certificate verification issue
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


# Initialize connection to database
driver = GraphDatabase.driver('bolt+s://<URI>:7687', auth=(',username', '<password'))


query = 'match (n:Event{name:"test"}) return n'

#Run Cypher query
with driver.session() as session:
    info = session.run(query)
    for item in info:
        print(item)
1
  • Were you still encountering this issue? I just tried connecting to a local Neo4j DB with the v5.5.0 driver without a problem.
    – Jalakoo
    Commented Feb 3, 2023 at 17:33

4 Answers 4

1

No way to know how you are connecting, but we do:

from neo4j import GraphDatabase
address="bolt://localhost:7687"
auth=('neo4j', "password")
driver = GraphDatabase.driver(address, auth=auth, encrypted=False)
....
3
  • Hi Gonzalo, i missed to update the connection script. Now i have added with my question and which is almost same as yours code and i have tried with encrypted=False and which wouldn't helped to solve the issue Commented Dec 6, 2022 at 16:44
  • Did you try with the url starting witrh bolt:// instead of bolt+s:// ? Commented Dec 6, 2022 at 17:55
  • I have tried , but it didn't work Commented Dec 7, 2022 at 9:29
0

Have you tried py2neo? I use below with dev running in docker and prod running Aura.

from py2neo import Graph
self.graph = Graph(os.getenv('DB_URI'), auth=(
            os.getenv('DB_USER'), os.getenv('DB_PASS')))

DB_URI is 'neo4j://0.0.0.0:7687' on dev and 'neo4j+s://xxxx' on prod

0

One reason for this to happen is different servers running. For example if you are running the neo4j on your local machine and accessing this DB from google-colab(which is essentialy a different server than your localhost), you might face this error, as it was case for me. To solve this issue, make sure your localhost is actually localhost. One way is to make a python script and run it locally. It will solve this issue. Remember colab shows [error 111].

Second method would be to replicate address. You may also look at the ngrok here which may help you impersonate IP.

0

If your Neo4j is running as a Docker container, try using the container name instead of localhost. In my case, it helped to resolve the issue.

from neo4j import GraphDatabase

AUTH = ("neo4j", "password")
# neo4j is the container name
URI = "neo4j://neo4j:7687"

with GraphDatabase.driver(URI, auth=AUTH) as driver:
    driver.verify_connectivity()
    print("Working")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.