equaeghe
equaeghe

Reputation: 1784

Cannot connect to remote Neo4j server using neo4j-shell

I have Neo4j 2.3.2 installed on a server whose firewall has ports 1337, 7474, 7473 open (verified using ncat). I can access the web-based console remotely and can access the shell locally, but I cannot access the shell remotely. Namely, when running path/to/neo4j-shell -v -host destination.example.org I get

ERROR (-v for expanded information):
        Connection refused
java.rmi.ConnectException: Connection refused to host: <server ip addres>; nested exception is: 
        java.net.ConnectException: Verbinding is geweigerd
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
        at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
        at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
        at com.sun.proxy.$Proxy1.welcome(Unknown Source)
        at org.neo4j.shell.impl.AbstractClient.sayHi(AbstractClient.java:257)
        at org.neo4j.shell.impl.RemoteClient.findRemoteServer(RemoteClient.java:70)
        at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:62)
        at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:45)
        at org.neo4j.shell.ShellLobby.newClient(ShellLobby.java:204)
        at org.neo4j.shell.StartClient.startRemote(StartClient.java:355)
        at org.neo4j.shell.StartClient.start(StartClient.java:226)
        at org.neo4j.shell.StartClient.main(StartClient.java:145)
Caused by: java.net.ConnectException: Verbinding is geweigerd
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at java.net.Socket.<init>(Socket.java:425)
        at java.net.Socket.<init>(Socket.java:208)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
        ... 14 more

In /var/lib/neo4j/conf/neo4j.properties, I have

# Enable shell server so that remote clients can connect via Neo4j shell.
remote_shell_enabled=true
# The network interface IP the shell will listen on (use 0.0.0.0 for all interfaces).
remote_shell_host=0.0.0.0
# The port the shell will listen on, default is 1337.
remote_shell_port=1337

Do I need to open other ports apart from the three mentioned? Is there any further configuration related to the shell I have missed?

Upvotes: 0

Views: 1304

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

neo4j-shell is based on Java RMI. There are couple of resources out there describing how to do firewalling for RMI. In fact it's pretty complex since RMI is doing dynamic port allocation.

Typically I run neo4j-shell locally over an ssh connection, this also gives you authentication and encryption - and you just need to open SSH port.

Upvotes: 2

Related Questions