4

I installed leiningen on my Ubuntu, but it throws a "Connection refused" error when I run lein repl. Here's the error:

$ lein repl
Exception in thread "Thread-4" 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 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:146)
    at clojure.lang.RestFn.invoke(RestFn.java:619)
    at user$eval540.invoke(NO_SOURCE_FILE:0)
    at clojure.lang.Compiler.eval(Compiler.java:6619)
    at clojure.lang.Compiler.eval(Compiler.java:6609)
    at clojure.lang.Compiler.eval(Compiler.java:6582)
    at clojure.core$eval.invoke(core.clj:2852)
    at leiningen.core.eval$fn__3577.invoke(eval.clj:304)
    at clojure.lang.MultiFn.invoke(MultiFn.java:231)
    at leiningen.core.eval$eval_in_project.invoke(eval.clj:326)
    at clojure.lang.AFn.applyToHelper(AFn.java:167)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.repl$server$fn__7443.invoke(repl.clj:201)
    at clojure.lang.AFn.applyToHelper(AFn.java:159)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.core$apply.invoke(core.clj:617)
    at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1788)
    at clojure.lang.RestFn.invoke(RestFn.java:425)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invoke(core.clj:621)
    at clojure.core$bound_fn_STAR_$fn__4102.doInvoke(core.clj:1810)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.AFn.run(AFn.java:24)
    at java.lang.Thread.run(Thread.java:722)

I had saw a question like this at github:lein repl error, but it doesn't solve my problem. Anyone knows why?

environment

  • os: ubuntu 12.04
  • leningen: Leiningen 2.3.4
  • java: 1.7.0_21
TacticalCoder
  • 6,275
  • 3
  • 31
  • 39
mahengyang
  • 289
  • 2
  • 16
  • I don't know much about Leiningen, so what I'll say could be all wrong or redundant, but it's been two days: `lein repl` starts two processes, a client and server, that talk over a tcp port. Maybe your system is configured to block the port that Leiningen uses by default. `lein help repl` shows how to experiment with alternative ports to see if that works. (Then you might have to learn how to change the tcp configuration.) The github discussion you linked provides other ways to experiment. – Mars Mar 04 '14 at 04:53

1 Answers1

7

First of all your stack trace is missing the Caused by... original exception.I didn't experienced it but I has been able to reproduce it getting the same stacktrace j plus these lines

Caused by: java.net.UnknownHostException: i7mito: System error
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:894)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1286)
        at java.net.InetAddress.getLocalHost(InetAddress.java:1462)
        ... 36 more

if I removed my machine name (i7mito) from the /etc/hosts/ file and I left it like

127.0.0.1 localhost

So my guess is that lein relies on the DNS to resolve your machine name ( i7mito in my case) to an IP address. The first step in this name resolution is your hosts file so I would check that first. I realized that the IP you bind to localhost doesn't matter, it's the IP that it's binded to the result of the hostname command what matters.

So if you ensure that your machine name it's mapped to 127.0.0.1 on the /etc/hosts file it may work. If it doesn't check your network configuration as other users are pointed out as it seems something related.

Hope it helps, of course this applies if you get the same extra lines on the stacktrace :)

Jaime Agudo
  • 8,076
  • 4
  • 30
  • 35