Irregular heartbeat?

I was just laying in bed and I started having heart palpitations. I’ve had them before but this was different. It was scary even though it was only a couple seconds long. My chest hurt and I actually thought I was dying