Issue
When syncing data from Segment sources to a Redshift destination, the sync fails with the error: "ERROR: permission denied for schema [schema_name] (SQLSTATE 42501)". The Segment UI may display: "Data could not be loaded due to an internal error."
Product
Segment Destinations
Environment
Segment Console
Cause
The Segment database user does not have the necessary permissions to access the target schema(s) in the Redshift cluster. This prevents the sync process from inspecting tables and loading data.
Resolution
- Grant the Segment user permission to create schemas in the target database (if schema management is handled by Segment):
GRANT CREATE ON DATABASE <database_name> TO <segment_user>; - Grant usage and create access on the relevant schema(s):
GRANT USAGE, CREATE ON SCHEMA <schema_name> TO <segment_user>; - Grant access to current and future tables within the schema(s):
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA <schema_name> TO <segment_user>;ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO <segment_user>; - After updating permissions, allow the next scheduled sync to run.
Additional Information
If multiple schemas are used, repeat the permission grants for each schema required by your Segment sync.