From Middle Low German hanenrey. The word is also attested in Middle High German, but it was rare and the later spread was without doubt based on Low German. The original sense seems to have been “capon”, that is a castrated cock. Further etymology unsettled.
- Hahnrei in Duden online