prestodb/presto · error · RedirectException
Failed to redirect
Error message
Failed to redirect
What it means
After confirming a desktop browser is supported, DesktopBrowserRedirectHandler attempts Desktop.browse(uri) to complete external authentication. If browsing throws an IOException (browser launch failure, no associated browser application, OS-level error), the handler wraps it in this RedirectException.
Source
Thrown at presto-client/src/main/java/com/facebook/presto/client/auth/external/DesktopBrowserRedirectHandler.java:38
import static java.awt.Desktop.getDesktop;
import static java.awt.Desktop.isDesktopSupported;
public final class DesktopBrowserRedirectHandler
implements RedirectHandler
{
@Override
public void redirectTo(URI uri)
throws RedirectException
{
if (!isDesktopSupported() || !getDesktop().isSupported(BROWSE)) {
throw new RedirectException("Desktop Browser is not available. Make sure your Java process is not in headless mode (-Djava.awt.headless=false)");
}
try {
getDesktop().browse(uri);
}
catch (IOException e) {
throw new RedirectException("Failed to redirect", e);
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Install and set a default browser on the machine (e.g. xdg-settings set default-web-browser firefox.desktop) and retry authentication.
- Check the wrapped IOException (getCause()) for the underlying OS error and fix it (install xdg-open, repair browser registration).
- Use a different RedirectHandler implementation that prints the auth URI for manual opening.
- Avoid the browser flow by using non-external authentication credentials.
Example fix
// before
handler.redirectTo(tokenUri); // fails on browser-less box
// after
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
handler.redirectTo(tokenUri);
} else {
System.out.println("Open manually: " + tokenUri);
} Defensive patterns
Strategy: try-catch
Validate before calling
java.awt.Desktop desktop = java.awt.Desktop.isDesktopSupported()
? java.awt.Desktop.getDesktop() : null;
if (desktop == null || !desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
throw new IllegalStateException("No desktop browser; print URI manually instead");
} Try / catch
try {
handler.redirectTo(uri);
} catch (RedirectException e) {
e.getCause().printStackTrace(); // IOException: fix default browser / xdg-open
System.out.println("Open manually: " + uri);
} Prevention
- Ensure a default browser is registered (xdg-settings / OS defaults).
- Install xdg-open on minimal Linux installs.
- Catch RedirectException and fall back to printing the URL for manual opening.
- Check e.getCause() (IOException) to diagnose the launch failure.
When it happens
Trigger: redirectTo(uri) succeeds the isSupported checks but Desktop.browse(uri) throws IOException — e.g. no default browser configured on the OS, xdg-open missing/broken on Linux, browser process fails to spawn, or an unsupported/badly formed URI is passed.
Common situations: Linux machines with no x-www-browser/xdg-open default; minimal desktop installs lacking a registered browser; corrupted default-browser associations; security software blocking AWT from spawning processes.
Related errors
- Desktop Browser is not available. Make sure your Java proces
- UNEXPECTED_ACCUMULO_ERROR
- UNEXPECTED_ACCUMULO_ERROR
- Failed to create Credentials from key
- Illegal character ':' found in username
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/69954e51c43da0a4.
Report an issue: GitHub.