How to get the nREPL port for a running REPL
Clarice Bouwer

Clarice Bouwer @cbillowes

About: Curious programmer sharing byte-sized knowledge on dev.to. Passionate about Git, GCP, TypeScript, Next.js, and DevTools. Enjoys collaborating with others and leading by example.

Location:
Mauritius
Joined:
May 30, 2018

How to get the nREPL port for a running REPL

Publish Date: Oct 26 '23
1 0

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.

There are two methods I know of.

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
Enter fullscreen mode Exit fullscreen mode

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

netstat -vanp tcp | grep 71141
Enter fullscreen mode Exit fullscreen mode

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

127.0.0.1.63361
Enter fullscreen mode Exit fullscreen mode

Use that port in Visual Studio Code.

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

See: https://stackoverflow.com/questions/77364142/how-do-i-get-the-nrepl-port-for-a-running-repl

Comments 0 total

    Add comment