Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure - how to connect to running REPL process remotely

How can I connect to a REPL session running on a remote server that I can access, for example via SSH?

like image 733
alex314159 Avatar asked Sep 22 '18 18:09

alex314159


Video Answer


2 Answers

This might be obvious to network specialists but took me a while to find out so documenting it here.

On the remote server, when launching your REPL application instead of just lein repl force binding to a port:

lein repl :start :port 40000

On your machine, connect to the remote server the normal way (for example via ssh). Then connect to your application this way:

lein repl :connect localhost:40000

That's it!

like image 83
alex314159 Avatar answered Oct 20 '22 05:10

alex314159


I just want to sum up the two answers above. It works on my machine:

On the remote machine

lein repl :start :port 40000

On the local machine

# SSH tunnel on one shell
ssh -NL 40000:localhost:40000 username@host

# Connect to the remote repl on another shell
lein repl :connect localhost:40000
like image 8
Minh Tuan Nguyen Avatar answered Oct 20 '22 07:10

Minh Tuan Nguyen