clojurecidernrepl

Cider nREPL using virtualbox error: connection broken by remote peer


Starting repl using:

lein repl :headless :port 4242

When I try to connect VIA cider connect I get the following error:

Connection closed unexpectedly (connection broken by remote peer)

When I try to connect VIA:

lein repl :connect 4242

I get the following error:

SocketException The transport's socket appears to have lost its connection to the nREPL server
        clojure.tools.nrepl.transport/bencode/fn--5154/fn--5155 (transport.clj:95)
        clojure.tools.nrepl.transport/bencode/fn--5154 (transport.clj:95)
        clojure.tools.nrepl.transport/fn-transport/fn--5126 (transport.clj:42)
        clojure.core/binding-conveyor-fn/fn--4676 (core.clj:1938)
        java.util.concurrent.FutureTask.run (FutureTask.java:266)
        java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
        java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
        java.lang.Thread.run (Thread.java:748)
Bye for now!

Solution

  • By default nrepl listens for connections only from the same computer. It does this by "binding" its listener to the IP address of the loopback network 127.0.0.1. If you want it to listen for connections from anywhere you can either bind it to 0.0.0.0 which is the any network address, or the address of a specific adapter.

    It looks like I needed to specify the host as 0.0.0.0 e.g.

    lein repl :headless :host 0.0.0.0 :port 4242