Troubleshooting

When the server answers UNAVAILABLE because of LinuxCNC, the trailing metadata carries a linuxcnc-grpc-reason entry. The errors guide lists every reason and status code.

UNAVAILABLE, reason not-connected

The message is “LinuxCNC is not running, or the server has not connected to it yet”. The server is up but not connected to LinuxCNC. Start LinuxCNC and the server connects within a few seconds:

linuxcnc /path/to/your/machine.ini

If LinuxCNC is running and the server still does not connect:

  • Run the server as the same user as LinuxCNC.
  • Check that the server’s Python can import the linuxcnc module. A venv needs --system-site-packages (see Installation).

With --require-linuxcnc the server exits at startup instead of waiting. See Starting before LinuxCNC.

UNAVAILABLE, reason linuxcnc-gone

The message starts “The LinuxCNC this server was attached to has shut down or been restarted”. The server found its LinuxCNC gone and is stopping; its log says how it found out. A supervisor such as systemd starts a new server, so try again shortly. If it happens after every LinuxCNC restart, check that the supervisor’s restart delay is at least RestartSec=2, and raise it if the error keeps coming (see Method 3: systemd service and When the server finds its LinuxCNC gone).

If it repeats after every server restart while LinuxCNC keeps running, a GUI probably died while it held LinuxCNC’s error buffer, and a server reading the error channel as always finds LinuxCNC gone each time. Restart LinuxCNC (see A holder that has died).

UNAVAILABLE, reason status-unreadable

The message starts “LinuxCNC’s status cannot be read right now”. LinuxCNC’s task holds the status buffer and is not running, for example because it was stopped. The server stays connected and keeps trying; call again after a short pause. If it appears while the task is running normally, raise --status-read-timeout. See A task stopped while it holds the status.

The server exits at startup

  • ModuleNotFoundError: No module named 'linuxcnc'. The venv was made without --system-site-packages, or the server runs as a user whose Python cannot see LinuxCNC’s modules (see Installation).
  • LinuxCNC 2.9 or newer is required: .... The installed LinuxCNC is too old (see Requirements).
  • With --require-linuxcnc, LinuxCNC was not running. Start LinuxCNC first, or drop the option so the server waits for it.

The server does not start with LinuxCNC

  • LinuxCNC’s log shows execv(linuxcnc-grpc): No such file or directory. loadusr did not find the program; give the absolute path to the venv’s linuxcnc-grpc (see Method 1: HAL file).
  • LinuxCNC never finishes starting. The HAL file uses loadusr -W; use loadusr -Wn grpc-hal-service or plain loadusr.
  • Nothing in the log. The line is in a POSTGUI_HALFILE that your GUI does not read (see Method 2: dedicated HAL file).

“Address already in use”

Another process is using the port. Find it, or start the server on another port:

sudo lsof -i :50051
linuxcnc-grpc --host 127.0.0.1 --port 50052

“Connection refused” from a client

  1. Check that the server is running.
  2. Check that the client uses the server’s host and port, or the local end of your SSH tunnel.
  3. On a trusted LAN, check the firewall rules (see Firewall).
  4. Check that the port is reachable: nc -zv hostname 50051.

More detail in the log

Start the server with --debug to log every RPC it receives (see Logging).