Using 9.5, this query:
The DISTINCT ON _expression_(s) must match the leftmost ORDER BY _expression_(s). The ORDER BY clause will normally contain additional _expression_(s) that determine the desired precedence of rows within each DISTINCT ON group.
Does the problem go away if you do that?
Geoff