This guide explains how to setup a VNC server on your phone.
Using x11vnc, which is in the Alpine repos. You need a running X server (e.g. running Xfce), then you just run x11vnc on the device in a terminal/tty and connect to it. From there, you can manipulate the previously running X server. You might need to specify the X server if x11vnc does not detect it (e.g. by passing
-display :0 to it or doing a
export DISPLAY=:0 before running it, assuming the display is at
This works for wayland sessions like Phosh. By default wayvnc listens to
Install wayvnc, and start a server listening to any network interface on the phone:
$ sudo apk add wayvnc (1/3) Installing aml (0.2.1-r0) (2/3) Installing neatvnc (0.4.0-r0) (3/3) Installing wayvnc (0.4.1-r0) Executing busybox-1.35.0-r13.trigger OK: 971 MiB in 563 packages $ wayvnc 0.0.0.0
Or listen to
172.16.42.1 on port
$ wayvnc 172.16.42.1 9999
After a server setup, use a client, for example, tigervnc-client to connect to the server
172.16.42.1:9999, and press Connect:
Have fun with it.
XDG_RUNTIME_DIR not set in the environment
This happens when
XDG_RUNTIME_DIR is not set, usually in SSH sessions.
$ wayvnc 0.0.0.0 error: XDG_RUNTIME_DIR not set in the environment. ERROR: Failed to initialise wayland
Just set it with:
$ export XDG_RUNTIME_DIR=/run/user/10000
And start the server again.
Connection refused/timed out
Check if your VNC server is started, and the port is open to the clients. By default, incoming packets from USB Networking are accepted by nftables on the phone .
But when connecting via Wi-Fi, you need to open the port.
If using port
5900, it's as simple as installing postmarketos-config-nftables-vncserverPMOS and restarting nftables:
# apk add postmarketos-config-nftables-vncserver (1/1) Installing postmarketos-config-nftables-vncserver (0.10-r0) Executing postmarketos-base-20-r0.trigger Configuring a getty on port ttyMSM0 with baud rate 115200 OK: 1006 MiB in 570 packages # service nftables restart * Stopping firewall ... [ ok ] * Loading nftables state and starting firewall ...
However, when connecting to a custom port like
9999, it requires to add a rule to accept the connection:
# nft add rule inet filter input iifname wlan0 tcp dport 9999 accept comment "Accept custom port over wifi"
No route to host
Check if the host even exists on the LAN.