"Pins and needles" is the colloquial term for paresthesia, a condition that is characterised by numbness, an uncomfortable tingly or prickling sensation or a feeling of heaviness in certain parts of the body, most commonly the extremities. Pins and needles in the legs is especially common, and can result due to minor disturbances such as pressure being applied to nerves or more serious conditions such as pinched nerves, neuropathy (nerve disease) and neuritis.
Pressure on Nerves
Perhaps the most common cause of pins and needles in the leg is pressure being put on nerves, specifically peripheral nerves that are responsible for sending your brain the signals for recognising physical touch or feeling. According to the Better Health Channel, when your legs are in a cramped or otherwise unusual position--which can happen at night without you even noticing--your legs' peripheral nerves can start to lose their functionality, and you will no longer be able to detect feeling in them. When you straighten or "shake out" your leg, you will likely start to feel the prickling sensation from which "pins and needles" gets its name. According the above source, this phenomenon is caused by your nerves "rebooting" and beginning to again send signals to the brain. It usually takes a few minutes before the nerves become completely functional, and that is why you may have some lingering loss of feeling.
Pins and needles that occur immediately following nightmares--which awaken you from sleep--can likely be explained away by the same cause: nerve pressure due to awkward leg positioning. However, according to Net Wellness, pins and needles in these instances can also be the result of awakening from a prolonged period of REM (rapid eye movement) sleep. During this type of sleep, the body essentially shuts down and is in a state of paralysis, while the mind is extremely active. If you wake up, you may not have feeling in your legs (or in other parts of your body). However, you should keep in mind that in both instances, nightmares themselves do not directly cause pins and needles.
Nerves that have been pinched by bones, cartilage, muscles or other tissues are another cause of pins and needles. According to the Cedars Sinai Medical Center, pinched nerves that result due to ruptured or herniated spinal discs are one of the leading culprits when it comes to pins and needles in the legs. The sensation typically occurs only in one leg, and will start in the buttocks or just behind the kneecap and continue down to the ankle or foot.
According to Better Health Channel, neuropathy, also referred to as nerve disease, causes peripheral nerves to become dysfunctional. This can produce chronic episodes of pins and needles, which are more severe and of longer duration than pressured or pinched nerves. The condition is commonly caused by diabetes, exposure to certain drugs and poisonous metals (like lead) and excessive alcohol consumption.
Neuritis is a very similar condition to neuropathy and has similar symptoms. However, according to Better Health Channel, neuritis is typified by the inflammation of peripheral nerves, as opposed to their shutting down. The condition is commonly caused by pernicious anaemia, excessive alcohol consumption and Guillian-Barre syndrome.