cancel
Showing results for 
Search instead for 
Did you mean: 

Neo4j Connection Issues

caschiffer
Node

Hello,

I have written a python script to execute queries on a remote Neo4j server. However, after updating my version of Neo4j last week I am having a difficult time connecting to the Neo4j database and, consequently, running my queries against it. I've tried bolt based and http based connections but to no avail. I've checked my neo4j.conf file to confirm that it matches my previous version where I could connect.

Below you will find the relevant section of my .conf file and the .log file where database start up and remote interface is successful., can someone help my troubleshoot my connection problems?

Neo4j.Log File

2020-02-25 00:30:54.128+0000 INFO ======== Neo4j 3.5.14 ========
2020-02-25 00:30:54.134+0000 INFO Starting...
2020-02-25 00:30:56.670+0000 INFO Deprecated index providers in use: lucene+native-2.0 (15 indexes). Use procedure 'db.indexes()' to see what indexes use which index provider.
2020-02-25 00:31:00.778+0000 INFO Bolt enabled on 0.0.0.0:7687.
2020-02-25 00:31:01.816+0000 INFO Started.
2020-02-25 00:31:02.849+0000 INFO Remote interface available at http://<MY IP>:7474/

Conf File

#*****************************************************************
#Network connector configuration
#*****************************************************************

#With default configuration Neo4j only accepts local connections.
#To accept non-local connections, uncomment this line:
dbms.connectors.default_listen_address=0.0.0.0
#dbms.connectors.default_listen_address=localhost

#You can also choose a specific network interface, and configure a non-default
#port for each connector, by setting their individual listen_address.

#The address at which this server can be reached by its clients. This may be the server's IP address or DNS name, or
#it may be the address of a reverse proxy which sits in front of the server. This setting may be overridden for
#individual connectors below.
#dbms.connectors.default_advertised_address=localhost
#dbms.connectors.default_advertised_address=0.0.0.0
dbms.connectors.default_advertised_address=<MY IP>

#You can also choose a specific advertised hostname or IP address, and
#configure an advertised port for each connector, by setting their
#individual advertised_address.

#Bolt connector
dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL
dbms.connector.bolt.listen_address=:7687

#HTTP Connector. There can be zero or one HTTP connectors.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=<MY IP>:7474

#HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=true
#dbms.connector.https.listen_address=:7473

#Number of Neo4j worker threads.
#dbms.threads.worker_count=

You can see that I was messing with the local connection in my default_advertised_address section.

Thanks for the help!

9 REPLIES 9

Looks fine to me.

  • How is python connecting?
  • To what IP?
  • Is it using localhost, or <my IP>, and to what connector/port?
  • What kind of error are you getting in python?
  • Have you tried a debugger, a network profiler, or stepping through the code?
  • Is there anything in the Neo4j logs?

In Python I was using the neo4j-connector method. It was working successfully with the local host connection (when I was running my computations on the same server as my hosted Neo4j graph.) However, I want to avoid graph and computation work on the same server to avoid crashing, etc.

When I was attempting to a nonlocalhost based connection I used the following port. IP-wise, we are using a AWS instance based IP address.

neo4j-connector
import neo4j
from neo4j import Connector
from neo4j import Statement
connector = neo4j.Connector('http:// MY IP :7474', (name, pw))

The error was as connection time out error and I ran into while working through a debugger on VScode and just running program.

Unfortunately, I didn't see anything in the Neo4j logs.

Thanks!

... nonlocalhost based connection... using a AWS instance... IP address.

connector = neo4j.Connector('http:// MY IP :7474', (name, pw))

You'll need to check a few things:

  1. Make sure you're using the right IP in the connector.
  2. Check basic connectivity
    • can you go in a browser to http:// MY IP :7474, and get to that Neo4j instance?
  3. Check the neo4j.conf connector config
    • dbms.connectors.default_listen_address= MY IP
    • dbms.connectors.default_advertised_address= MY IP

Once you're going from machine to machine, hostnames will simplify networking. A simple temp shortcut is to set default_advertised_address=anynameyouwant, then add that as an entry to your hosts file: MY IP anynameyouwant. Then you could simply connect to http://anynameyouwant:7474.

Hey there, so I changed the values:

  • dbms.connectors.default_listen_address=
  • dbms.connectors.default_advertised_address=

to the respective IP address where I my graph db is stored.

Additionally, I verified that I am using the right IP and that my basic connectivity works from the browser. (On the note of the browser, I am able to connect from a browser on another machine and from the machine where the graph db is hosted.)

However, I am still seeing a failure as shown below:

requests.exceptions.ConnectionError: HTTPConnectionPool(host=' MY IP', port=7474): Max retries exceeded with url: /db/data/transaction/commit (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f60fb350898>: Failed to establish a new connection: [Errno 110] Connection timed out',)

Will changing the host name work in this case?

Additionally, I tried using the bolt connector to troubleshoot but it failed as well. The error was:

  • requests.exceptions.InvalidSchema: No connection adapters were found for 'bolt:// MY IP:7687/

I checked my conf files and my log files again to make sure it was enabled as well and it was according to below.

Log File

2020-02-28 19:58:57.515+0000 INFO ======== Neo4j 3.5.14 ========
2020-02-28 19:58:57.531+0000 INFO Starting...
2020-02-28 19:59:02.946+0000 INFO Deprecated index providers in use: lucene+native-2.0 (15 indexes). Use procedure 'db.indexes()' to see what indexes use which index provider.
2020-02-28 19:59:11.567+0000 INFO Bolt enabled on :7687.
2020-02-28 19:59:13.922+0000 INFO Started.
2020-02-28 19:59:15.934+0000 INFO Remote interface available at http:// :7474/

Conf File

#With default configuration Neo4j only accepts local connections.
#To accept non-local connections, uncomment this line:
#dbms.connectors.default_listen_address=0.0.0.0
dbms.connectors.default_listen_address= < MY IP >
#dbms.connectors.default_listen_address=localhost

#You can also choose a specific network interface, and configure a non-default
#port for each connector, by setting their individual listen_address.

#The address at which this server can be reached by its clients. This may be the server's IP address or DNS name, or
#it may be the address of a reverse proxy which sits in front of the server. This setting may be overridden for
#individual connectors below.
#dbms.connectors.default_advertised_address=localhost
#dbms.connectors.default_advertised_address=0.0.0.0
dbms.connectors.default_advertised_address= < MY IP >

#You can also choose a specific advertised hostname or IP address, and
#configure an advertised port for each connector, by setting their
#individual advertised_address.

#Bolt connector
dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL
dbms.connector.bolt.listen_address=:7687

#HTTP Connector. There can be zero or one HTTP connectors.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474

#HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=true
#dbms.connector.https.listen_address=:7473

I can't see a reason why you wouldn't be able to connect to the Neo4j instance.

Will changing the host name work in this case?

Using a hostname to connect probably will not solve this issue, but it might be worth a try anyway.

The browser uses those same ports and hosts, so if it can connect to bolt, your app shouldn't have any trouble. Maybe the script, or the environment it is ran in, is blocking or redirecting the traffic. Might also be worth checking local machine firewalls. Failing that, wireshark.

Ok, I'll check it out. Thanks.

Can you please check the debug.log and security.log to see if you see any errors.

I did and I wasn't seeing any connection errors

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.