Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Accessing Neo4j server remotely

Hi, I am hosting a Neo4j server on my laptop, and I am trying to access it via an amazon EC2 instance. I am using Neo4j desktop to run the server.

I've configured my server to accept external traffic:


I use a reverse ssh from my laptop -> ec2 instance to expose ports 7474 and 7487. I use a reverse ssh from server -> client because my laptop is private and I don't want to port forward from my public IP.

ssh -R7687:localhost:7687 -R7474:localhost:7474 ec2-user@EC2IP

On my EC2 instance, I am using self.driver = GraphDatabase.driver(bolt://localhost:7687", auth=auth, max_transaction_retry_time=20)to access the database. It fails with error

Failed to establish connection to ResolvedIPv6Address(('::1', 7687, 0, 0)) (reason [Errno 99] Cannot assign requested address))
2022-01-20 00:36:28 neo4j WARNING: Transaction failed and will be retried in 1.6414348276387707s (Couldn't connect to localhost:7687 (resolved to ('', '[::1]:7687')):


The name "localhost" is a special reserved name that always refers to whatever host you're on. So the reason this is failing is that on your EC2 instance, you're connecting to "localhost" which is the EC2 instance, not your laptop.

Your reverse SSH will probably also not work because it's referring only to localhost.

The only way to get this to work would be to expose network ports from your laptop onto the internet, under a given DNS name or IP address, so that you can connect to that address from EC2. Whether you did that with SSH or something else would be fine either way.