{"record":{"id":"3509ff4d4e8bcdd9","repo":"prestodb/presto","slug":"desktop-browser-is-not-available-make-sure-your-j","errorCode":null,"errorMessage":"Desktop Browser is not available. Make sure your Java process is not in headless mode (-Djava.awt.headless=false)","messagePattern":"Desktop Browser is not available\\. Make sure your Java process is not in headless mode \\(-Djava\\.awt\\.headless=false\\)","errorType":"exception","errorClass":"RedirectException","httpStatus":null,"severity":"error","filePath":"presto-client/src/main/java/com/facebook/presto/client/auth/external/DesktopBrowserRedirectHandler.java","lineNumber":31,"sourceCode":" */\npackage com.facebook.presto.client.auth.external;\n\nimport java.io.IOException;\nimport java.net.URI;\n\nimport static java.awt.Desktop.Action.BROWSE;\nimport static java.awt.Desktop.getDesktop;\nimport static java.awt.Desktop.isDesktopSupported;\n\npublic final class DesktopBrowserRedirectHandler\n        implements RedirectHandler\n{\n    @Override\n    public void redirectTo(URI uri)\n            throws RedirectException\n    {\n        if (!isDesktopSupported() || !getDesktop().isSupported(BROWSE)) {\n            throw new RedirectException(\"Desktop Browser is not available. Make sure your Java process is not in headless mode (-Djava.awt.headless=false)\");\n        }\n\n        try {\n            getDesktop().browse(uri);\n        }\n        catch (IOException e) {\n            throw new RedirectException(\"Failed to redirect\", e);\n        }\n    }\n}\n","sourceCodeStart":13,"sourceCodeEnd":42,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-client/src/main/java/com/facebook/presto/client/auth/external/DesktopBrowserRedirectHandler.java#L13-L42","documentation":"DesktopBrowserRedirectHandler handles external-authentication redirects by opening the authorization URI in the local desktop browser via java.awt.Desktop. If no desktop is supported or BROWSE is unsupported (typical on servers/headless JVMs), it throws this RedirectException so the external authentication flow cannot proceed.","triggerScenarios":"Running external authentication (e.g. Presto CLI with an external authenticator) on a JVM started with java.awt.headless=true, or on a machine with no display/no desktop browser, then ExternalAuthenticator calls redirectTo(uri) and isDesktopSupported()/Desktop.isSupported(BROWSE) returns false.","commonSituations":"Running the Presto CLI inside a Docker container, CI job, SSH session without X11 forwarding, or any server-side Java process where AWT is headless and no browser exists.","solutions":["Run the client on a workstation with a desktop environment and a default browser, ensuring the JVM is not headless (-Djava.awt.headless=false).","Use an alternative redirect handler that does not require a desktop browser (e.g. a handler that prints the URI for manual opening, or token-based authentication).","If X11 forwarding is intended, connect with ssh -X/-Y and verify DISPLAY is set.","Pre-authorize out-of-band (service account, basic/Kerberos auth) to avoid the external-auth browser flow entirely."],"exampleFix":"// before\njava -jar presto-cli ... # headless container\n// after\njava -Djava.awt.headless=false -jar presto-cli ...   # run on a desktop machine with a browser","handlingStrategy":"fallback","validationCode":"boolean desktopBrowserAvailable = java.awt.Desktop.isDesktopSupported()\n    && java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.BROWSE);\nif (!desktopBrowserAvailable) {\n    System.out.println(\"Open this URL manually: \" + authUri);\n}","typeGuard":"boolean canBrowse(URI uri) {\n    return java.awt.Desktop.isDesktopSupported()\n        && java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.BROWSE);\n}","tryCatchPattern":"try {\n    handler.redirectTo(uri);\n} catch (RedirectException e) {\n    // fallback: print URL for manual browser opening or switch auth method\n    System.out.println(\"Open manually: \" + uri);\n}","preventionTips":["Run interactive external auth only on desktop machines with a default browser.","Do not run the CLI in headless containers/CI for external authentication; use token or basic auth there.","Start the JVM with -Djava.awt.headless=false when a display is available.","For remote servers, use SSH port forwarding plus a local browser or copy the auth URL manually."],"tags":["authentication","desktop","headless","redirect"],"backgroundTag":"headless-browser-unavailable","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}