Clojure repl连接已关闭

时间:2015-06-12 09:31:21

标签: clojure

我是clojure的新手,在我完成第一个clojure Hello World项目之后,我尝试启动repl但是我遇到了Connection denied错误。请帮忙!

我输入的命令是lein repl

Exception in thread "main" java.net.ConnectException: Connection refused, compiling:(/private/var/folders/wz/jk4mqxs57fb4m27sly8fyqkh0000gn/T/form-init1330852264199133435.clj:1:124)

        at clojure.lang.Compiler.load(Compiler.java:7142)
        at clojure.lang.Compiler.loadFile(Compiler.java:7086)
        at clojure.main$load_script.invoke(main.clj:274)
        at clojure.main$init_opt.invoke(main.clj:279)
        at clojure.main$initialize.invoke(main.clj:307)
        at clojure.main$null_opt.invoke(main.clj:342)
        at clojure.main$main.doInvoke(main.clj:420)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:383)
        at clojure.lang.AFn.applyToHelper(AFn.java:156)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)

Caused by: java.net.ConnectException: Connection refused

        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at java.net.Socket.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)
        at clojure.tools.nrepl$connect.doInvoke(nrepl.clj:184)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.tools.nrepl.ack$send_ack.invoke(ack.clj:47)
        at clojure.tools.nrepl.server$start_server.doInvoke(server.clj:153)
        at clojure.lang.RestFn.invoke(RestFn.java:619)
        at clojure_noob.core$eval1096.invoke(form-init1330852264199133435.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6703)
        at clojure.lang.Compiler.eval(Compiler.java:6693)
        at clojure.lang.Compiler.eval(Compiler.java:6693)
        at clojure.lang.Compiler.load(Compiler.java:7130)
        ... 11 more

1 个答案:

答案 0 :(得分:8)

遇到同样的问题,可以通过运行无头repl,然后在另一个shell中连接到它来解决这个问题

> lein repl :headless
nREPL server started on port 9991 on host 127.0.0.1 - nrepl://127.0.0.1:9991

然后在另一个shell

> lein repl :connect nrepl://127.0.0.1:9991