Lisp server on ESP32 error connection failed



When calling the (lisp-server) from example
I always get error 'with-client ’ connection failed
Listening … is never printed

(defun lisp-server ()
  (with-client (s (ip '(192 168 0 207)) 1234)
    (print "Listening...")
     (unless (= 0 (available s))
       (let ((line (read-line s)))
         (print line)
         (println (eval (read-from-string line)) s)))
     (delay 1000))))

where is my laptop ip
and the telnet i do to the (wifi-localip) result at port 1234
–> connection refused (run as admin)

any suggestion?

Kind regards,



I’ve checked this example, and verified that you should be able to get it to work.

The ip address you give to the lisp-server function should be the ip address of your computer on the local network, not the ip address returned by (wifi-localip). I’ve slightly improved the example to make it easier to enter this ip address when you run the function.

I haven’t tried telnet as it’s not available on macOS, but with nc (netcat) you just specify a port to listen on, no ip address.

Let me know if you manage to get it working.



I get the exact same error

3816> (lisp-server 192 168 1 56)
[E][WiFiClient.cpp:213] connect(): lwip_connect_r: 104
Error: ‘with-client’ connection failed

I’m very new at this, so not entirely sure where to begin debugging.
I’m using uLisp ESP Version 2.4, Arduino-1.8 and it’s Espressif’s arduino-esp32 “1.0.0”


The port 1234 isn’t open only port 80?


Can you explain what your screenshot is showing? Is it showing it working, or not working?


Hi David,

The lisp-server example, I never got it working.
I used Zenmap to scan the open ports from my ESP32
Only port 80 is open, and I don’t know why since i use 1234 like in the example.
On the Serial link screen, itt says: Listening …
With Putty or telnet i can’t connect to the ESP32
telnet 1234 gives no result is the adress i get from the (wifi-localip) command
The lisp-server i give the IP from my laptop.

Kind regards,



Might you have a firewall blocking non-standard ports such as 1234?


I tryed ports <1000 too, no difference


Have you tried doing:

telnet 1234

I think you should be telnetting to the lisp-server.



this is a list of all my actions
in cmd window: --chip ESP32 --port COM7 erase_flash
download this file into the ESP32 after uncomment resetautorun

upload these defuns:

(defun ip (lis)
  (let ((x 0))
    (mapc (lambda (n) (setq x (+ (ash x 8) n))) (reverse lis))

(defun println (x s) (princ x s) (princ #\return s) (princ #\newline s))

(defun lisp-server (&rest iplist)
  (with-client (s (ip iplist) 454)
    (print "Listening...")
     (unless (= 0 (available s))
       (let ((line (read-line s)))
         (print line)
         (println (eval (read-from-string line)) s)))
     (delay 1000))))

(defun do ()
	(wifi-connect "telenet-xxxx "xxxxxxxxxxx")
	(lisp-server 192 168 0 225))

Then (save-image 'do)

from that moment i can ping
but Zenmap can’t find an open port
So i can not connect with telnet


Have you executed:


to run the list-server command? It’s not in your transcript.


It is in the do definition


Just to check; the command:

(lisp-server 192 168 0 225)

needs to be running, with Lisp hung up displaying:


before you can telnet to the Lisp server, and you can’t run the telnet command from uLisp; you have to run it from your computer’s command line.


I removed the (lisp-server 192 168 0 225) line from the 'do image and execute it from the serial monitor after a reset. First I check the local IP from the ESP32 =>

I try (lisp-server 192 168 0 225) => nil
and (lisp-server 192 168 0 233) => nil the last one is the IP from my laptop

I can still enter lisp commands from the serial monitor


Hmm i did try that before
For the moment i don’t execute do in the transcript
Since i (save-image 'do)
I understand wit resetautorun the function do will be executed after reset
so i run it by resetting the ESP32


Hi David,

It became quiet on this thread.
I’m stuck here since 2018
I would like to be able to make that lisp-server running
The idea talk to a lisp-server, or let lisp-servers talk among each other looks so attractive
Always get Error: ‘with-client’ connection failed

I don’t know exactly what IP to give to the server: The one from my laptop, or the ESP own IP address when it connects to the home WiFi? I understood it should be the one from my laptop.

I also dont understand your ip function, if i translate each nuner to a byte and then put all bytes next to each other in same order, then give it to the ulisp interpreter, i get another number then the ip function provides

Why doesn’t it simply show: Listening … and then I can connect with Putty?
I dont understand the with-client function, should it wait to get connected from my laptop?
Why does it say connection failed before i can try to connect ?

Kind regards,



Here’s a complete sequence that worked for me just now, using ESP uLisp 4.0b on an Adafruit ESP32 Feather:

1. Connect to your Wi-Fi with your network name and password:

> (wifi-connect "Home" "secret")

2. Define the lisp-server function and the utilities:

(defun ip (lis)
  (let ((x 0))
    (mapc (lambda (n) (setq x (+ (ash x 8) n))) (reverse lis))

(defun println (x s) (princ x s) (princ #\return s) (princ #\newline s))

(defun lisp-server (&rest iplist)
  (with-client (s (ip iplist) 8080)
    (print "Listening...")
     (unless (= 0 (available s))
       (let ((line (read-line s)))
         (print line)
         (println (eval (read-from-string line)) s)))
     (delay 1000))))

Here I’ve used 8080 as the port number.

3. Discover the IP address of your remote computer

This can be the one connected to the ESP32, or any other computer on the network.

For example you can use ipconfig at the terminal:

$ ipconfig getifaddr en0

or you might need to use en1.

4. Start telnet from the terminal on your remote computer to the port you’re going to use:

$ nc -l 8080

It should hang up.

5. Run lisp-server with the IP address of the remote computer:

> (lisp-server 10 0 1 44)


If you omitted to start the telnet session in the previous step it will just return with nil.

6. Enter some Lisp

Now at the telnet session you can type:

(defun sq (x) (* x x))

and it will echo


Then you can type:

(sq 123)

and it will echo


To exit from the telnet session press Ctrl-Z.

In one of your posts you mentioned running lisp-server using uLisp’s autorun feature, by restarting the ESP32. That may be interfering with the Wi-Fi connection, so try following my sequence without restarting the ESP32.

Let me know how you get on!

Update: added the utilities you also need to install.


Hi David,

Yes it finally works.
Thank you so much.
I installed ncat to listen to port 8080.
ncat -l 8080 did the job.

With save-image no result until now.
Then it makes not much sense to send commands over wifi, since it is still connected to the USB port.

It should be an autonomous lisp-server accessible over wifi.

I will experiment more with it.

In the end I would like to be able to send commands to one of more lisp-servers on esp processors and also let them send commands to each other.

Since this took me 4 years, … 😁

Kind regards

Frank Weytjens


Glad it’s finally working!

The example is not very useful when you run telnet on your own computer, but you can also run telnet on another computer elsewhere on the network. In this case you do:

(lisp-server 10 0 1 44)

where is the address of the remote computer. I’ve just checked that it all works.

Thanks for the feedback - I’ll update my Wi-Fi examples page with a fuller description so that hopefully it won’t take anyone else 4 years to get it working!


I really just intended it as a demo, but to make it useful in the way you describe the uLisp command with-client should just wait, rather than returning with nil, if it doesn’t find the port open.

This could perhaps be handled by an additional parameter to with-client. What do you think?