roymond
roymond

Reputation: 147

neo4j-shell "connection refused" error

I'm running 2.0.0 M06 on a Mac (ML)

Neo4j is running and the web console works fine. But when I try to connect via Neo4j-shell it fails. Everything was fine on Wednesday, but after attempting a Postgres install (part of the MusicBrainz Neo4j project) this problem came up:

sneedham-pd:neo4j-community-2.0.0-M06 username$ **bin/neo4j start**
Using additional JVM arguments:  -server -XX:+DisableExplicitGC -Dorg.neo4j.server.properties=conf/neo4j-server.properties -Djava.util.logging.config.file=conf/logging.properties -Dlog4j.configuration=file:conf/log4j.properties -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
Starting Neo4j Server...WARNING: not changing user
process [694]... waiting for server to be ready..... OK.
http://localhost:7474/ is ready.

sneedham-pd:neo4j-community-2.0.0-M06 username$ **bin/neo4j-shell -v**
ERROR (-v for expanded information):
    Connection refused
java.rmi.ConnectException: Connection refused to host: 172.16.31.31; nested exception is: 
    java.net.ConnectException: Connection refused
    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:128)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
    at com.sun.proxy.$Proxy1.welcome(Unknown Source)
    at org.neo4j.shell.impl.AbstractClient.sayHi(AbstractClient.java:206)
    at org.neo4j.shell.impl.RemoteClient.findRemoteServer(RemoteClient.java:63)
    at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:55)
    at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:43)
    at org.neo4j.shell.ShellLobby.newClient(ShellLobby.java:165)
    at org.neo4j.shell.StartClient.startRemote(StartClient.java:289)
    at org.neo4j.shell.StartClient.start(StartClient.java:167)
    at org.neo4j.shell.StartClient.main(StartClient.java:119)
Caused by: java.net.ConnectException: Connection refused
    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:391)
    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:146)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
    ... 14 more

 -host      Domain name or IP of host to connect to (default: localhost)
 -port      Port of host to connect to (default: 1337)
 -name      RMI name, i.e. rmi://<host>:<port>/<name> (default: shell)
 -pid       Process ID to connect to
 -c         Command line to execute. After executing it the shell exits
 -file      File containing commands to execute. After executing it the shell exits
 -readonly  Connect in readonly mode
 -path      Points to a neo4j db path so that a local server can be started there
 -config    Points to a config file when starting a local server

Example arguments for remote:
    -port 1337
    -host 192.168.1.234 -port 1337 -name shell
    -host localhost -readonly
    ...or no arguments for default values
Example arguments for local:
    -path /path/to/db
    -path /path/to/db -config /path/to/neo4j.config
    -path /path/to/db -readonly

Upvotes: 8

Views: 17365

Answers (5)

ekcrisp
ekcrisp

Reputation: 1911

In your neo4j.conf you have to uncomment the lines related to using the neo4j-shell

# Enable a remote shell server which Neo4j Shell clients can log in to.
dbms.shell.enabled=true
# The network interface IP the shell will listen on (use 0.0.0.0 for all interfaces).
dbms.shell.host=127.0.0.1
# The port the shell will listen on, default is 1337.
dbms.shell.port=1337

This fixed the issue for me

Upvotes: 6

Jaymin Gajjar
Jaymin Gajjar

Reputation: 146

You can export neo4j database without host if you have database folder using following command :

neo4j-shell -path /var/lib/neo4j/data/databases/graph.db -c dump > export_data.cypher -v

It will create file called "export_data.cypher" in your current directory.

Hope it helps.

Upvotes: 0

NAS
NAS

Reputation: 145

Open command prompt: enter image description here

C:\Users\nsh004\Documents\Neo4j>Neo4jShell -path C:\Users\nshinde004\Documen ts\Neo4j\Demo1 -file load.cql

This worked for me. we have to provide the path for database. Once I provided it worked!! :-)

Upvotes: 1

Vladyslav Kurmaz
Vladyslav Kurmaz

Reputation: 66

I faced with the same issue.

My configuration is:

  • windows-7-x32
  • neo4j-2.1.4
  • neo4j starts as a service

The Neo4jShell.bat works file util I close my notebook (sleep mode). After resume, looks like neo4j process somehow "loose" port to listen. Depends on situation 1337 port could be used by different processes

[nvstreamsvc.exe] TCP 127.0.0.1:1337 notebook:0 LISTENING

[Dropbox.exe] TCP 127.0.0.1:1337 notebook:0 LISTENING

In my case solution is to restart Neo4j-Server service via Windows Task Manager.

I hope this will help.

Upvotes: 0

Igor Chubin
Igor Chubin

Reputation: 64613

The point is that server is bound to localhost (127.0.0.1) and the shell tries to connect to 172.16.31.31, that is another network interface, not loopback. That is the reason why you get here connection refused.

Upvotes: 1

Related Questions