How to configure X11 forwarding to Mac OS X

X11 forwarding Mac OSX

This guide is confirmed to work on Mac OS X 10.8 “Mountain Lion” and above through OS 13 “Ventura”. All AlmaLinux and CentOS distributions are covered.


Configure X11 forwarding on the AlmaLinux server.

Install XQuartz, an X emulator, on the Mac.

On the Mac OS Terminal and enable Indirect GLX (iGLX), required to run applications that need OpenGL support at the X server side.

For Quartz 2.7 or earlier vesions, run.

$ defaults write org.macosforge.xquartz.X11 enable_iglx -bool true

For Quartz 2.8 or later vesions, run.

$ defaults write org.xquartz.X11 enable_iglx -bool true

“X11” in the domain name above should be in capitals, which is case sensitive.

Start Quartz.


If -X does not work, use -Y, in this case.

Check if the DISPLAY environment variable is set and iGLX works.

$ echo $DISPLAY
localhost:10.0
$ glxinfo
libGL error: No matching fbConfigs or visuals found
name of display: localhost:10.0
libGL error: failed to load driver: swrast
display: localhost:10  screen: 0
direct rendering: No
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_visual_info, 
    GLX_EXT_visual_rating, GLX_OML_swap_method, GLX_SGIS_multisample, 
    GLX_SGIX_fbconfig

The libGL error messages can be ignored

If xdpyinfo shows an error message like below.

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  26
  Current serial number in output stream:  27

Check if iGLX is enabled on the Mac OS X.

$ defaults read org.macosforge.xquartz.X11 enable_iglx
or
$ defaults read org.xquartz.X11 enable_iglx

Sometimes after starting the session, messages like this are shown each time you try to run an X11 program.

xdpyinfo:  unable to open display "localhost:10".

Try starting the SSH session from an xterm launched from XQuartz, not from a Mac OS Terminal.