Those stars and colours you see when you rub your eyes are called phosphenes.
Have you ever closed your eyes, rubbed them and seen stars? Or at least little pops of light? It turns out that those pops of light have a name: phosphenes.
They are a phenomenon characterized by seeing light without light actually entering the eye. This rubbing mechanically stimulates the cells of the retina causing this effect. Sometimes, these phosphenes can still be seen for moments after you open your eyes.
Meditators have also reported experiencing phosphenes, and they have actually been known since antiquity. Ancient Greeks described them. Other reasons people ‘see stars’ are because of sneezing, coughing, blowing your nose or receiving a blow to the head.