skip to Main Content

I want to connect to a running REPL on my local machine outside of Visual Studio Code. The terminal output is cleared or truncated depending on the terminal.

Is it possible for me to find the port number that the REPL is running on via a shell command or a Clojure function?

2

Answers


  1. Chosen as BEST ANSWER

    Grep the processes for the name of the project that is running on the JVM. This will give a process ID. Eg. 71141

    ps aux | grep name-of-the-project
    

    Grep the network-related information such as open connections, open socket ports with the process ID from above.

    netstat -vanp tcp | grep 71141
    

    Find the loopback IP with the associate port. Eg. 63361

    127.0.0.1.63361
    

    Use that port in Visual Studio Code.


    To find the port from the Clojure REPL: (slurp ".nrepl-port")


  2. When the nrepl server starts, it generally writes the port number it is using into the file .nrepl-port in the project directory. Most tooling (e.g. emacs CIDER or lein repl :connect) use this file.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search