Skip to main content

Engine 406 and 502 errors

Reproduced. Saving or testing a Trino connection, or creating a dataset on it, fails with engine: http 406 Not Acceptable or with 502 Bad Gateway. This is the most common first-run failure with a Trino you did not provision through Egret.

What you see​

WhereMessage
Test on a connection, or POST /api/ws/{workspace}/databases/testThe request answers 200, but the body says {"ok":false,"detail":"engine: http 406 Not Acceptable"}
Creating a dataset, POST /api/ws/{workspace}/datasetsHTTP 502 with {"error":"engine: engine: http 406 Not Acceptable"}
A query in SQL LabThe query status ends as failed with an engine: error
Saving a connection through the APIIt saves, with status unknown: the connection is stored without being proven, and the failure appears at the first use or on Test.

Cause​

Egret sends the X-Forwarded-Proto header to Trino. A stock Trino rejects forwarded headers with HTTP 406 Not Acceptable unless it is told to trust them. Egret then has no useful answer for the caller and reports a generic 502 Bad Gateway on routes that call the engine as part of their work.

You can confirm it from the machine that runs Egret:

curl -s -o /dev/null -w '%{http_code}\n' -H 'X-Forwarded-Proto: http' -H 'X-Trino-User: probe' http://<trino>:8080/v1/info
# 406 on a stock Trino
curl -s -o /dev/null -w '%{http_code}\n' -H 'X-Trino-User: probe' http://<trino>:8080/v1/info
# 200

If the first request answers 406 and the second does not, this is the cause.

Fix​

Set http-server.process-forwarded=true in the coordinator's config.properties and restart Trino:

coordinator=true
node-scheduler.include-coordinator=true
discovery.uri=http://localhost:8080
http-server.process-forwarded=true

In the Docker image, mount the file over /etc/trino/config.properties. The Trino in the repository's compose file and the engines Egret provisions already have the setting, so you meet the error only with a Trino you run yourself.

After the restart, Test on the connection answers {"ok":true,"detail":"SELECT 1 ok"} (reproduced against a Trino with the setting).

SymptomCause
connect: error sending request for url (...)Egret cannot reach the host and port at all; see Queries fail.

Further reading​