diff --git a/libepoxy/meson.build b/libepoxy/meson.build
index bb283ed8ded440fafefc78ed2f29232cdeb2bfb2..93b9c1a381fd93561aedf4f7179e96a8d9d137fd 100644
--- a/libepoxy/meson.build
+++ b/libepoxy/meson.build
@@ -1,4 +1,4 @@
-project('libepoxy', 'c', version: '1.5.7',
+project('libepoxy', 'c', version: '1.5.9',
         default_options: [
           'buildtype=debugoptimized',
           'c_std=gnu99',
diff --git a/libepoxy/src/dispatch_common.c b/libepoxy/src/dispatch_common.c
index 62b71349d25690772d90ae915f7cedab55ae6896..592df386bd3a7d5a47aa65f3fd7d07cbbaaad845 100644
--- a/libepoxy/src/dispatch_common.c
+++ b/libepoxy/src/dispatch_common.c
@@ -670,17 +670,23 @@ epoxy_load_gl(void)
     get_dlopen_handle(&api.gl_handle, OPENGL_LIB, true, true);
 #else
 
+    // Prefer GLX_LIB over OPENGL_LIB to maintain existing behavior.
+    // Using the inverse ordering OPENGL_LIB -> GLX_LIB, causes issues such as:
+    // https://github.com/anholt/libepoxy/issues/240 (apitrace missing calls)
+    // https://github.com/anholt/libepoxy/issues/252 (Xorg boot crash)
+    get_dlopen_handle(&api.glx_handle, GLX_LIB, false, true);
+    api.gl_handle = api.glx_handle;
+
 #if defined(OPENGL_LIB)
     if (!api.gl_handle)
-	get_dlopen_handle(&api.gl_handle, OPENGL_LIB, false, true);
+        get_dlopen_handle(&api.gl_handle, OPENGL_LIB, false, true);
 #endif
+
     if (!api.gl_handle) {
-	get_dlopen_handle(&api.gl_handle, GLX_LIB, true, true);
-#if PLATFORM_HAS_GLX
-        if (!api.glx_handle)
-	    api.glx_handle = api.gl_handle;
-#endif
+        fprintf(stderr, "Couldn't open %s or %s\n", GLX_LIB, OPENGL_LIB);
+        abort();
     }
+
 #endif
 }