Your dosage was likely too high. I had the same issue using the smallest dose I could find at the pharmacy (5mg) and it was totally fixed by going to a pill one fifteenth of the dosage that I procured online.
I wouldn't be surprised, they were plain OTC 10mg pills but as I read in an article posted fairly recently on HN I learned that the required dose is often much, much smaller than that. My foray with melatonin was a few years ago and I'm not having trouble sleeping now so I haven't dipped my toes into it again.
Wait until you read this:
"Oral administration of 1,000 mg a day of melatonin to five adults for 25 to 30 days resulted in drowsiness being noted as an adverse effect. There were no severe and/or irreversible impacts on clinical parameters (blood pressure, heart rate, ECG, serum chemistry, urine analysis) in these people."
Source: Nordlund JJ, Lerner AB. The effects of oral melatonin on skin color and on the release of pituitary hormones. J Clin Endocrinol Metab. 1977
As is mine, now. Back in the wild days of 2016 or so advice online said "just go get some melatonin and you'll sleep!" and the bottle said to take 1 or 2 an hour before you want to sleep, so off I went.
It seems like that would be very hard to get a consistent dose with such a small amount. Those cuts would need to be extremely precise. It would be more reliable to buy the 1mg children’s dose and cut them in half.
I did this too. Someone had told me at one point the best thing to do to ingest it is to crush it somehow and keep it under your tongue for 30 seconds. And I also knew I wanted very small amounts of the pills I had. So I would take the tiniest nibbles of the chalky pills and leave them in my mouth for a while, until I could feel the effects slightly come on. Grew weirdly fond of the taste.