No, your bed and the way you slept is not the reason your back hurts in the morning.
Many people like to blame their mattress or "sleeping wrong" for their back pain, but the fact is, the reason you have back pain is due to normal changes that you can't and can control.
What happens to your spine as you sleep?
As you sleep, laying down, your discs are no longer under the force of gravity. During this time, fluid (nutrients) seep from the vertebrae through the vertebral end plate, into the nucleus of the discs. The fluid nourishes the nucleus, and causes it to swell.
When you wake up in the morning, and stand up, the gravity and pressure slowly forces this fluid out of the nucleus of the disc. You are actually taller in the morning than in the evening.
The nucleus of the disc swelling isn't exactly the reason for the pain or discomfort either, but does contribute to it. You can't control it, nor would you want to stop it from happening because it's the only way your discs can get nutrients, and flush out waste.
So how does this normal occurrence contribute to pain? It causes tension on other ligaments surround the nucleus of the disc, and of the spine that slowly over time because less elastic or stretchy.
The reason you have pain is because your ligaments are becoming less elastic, and aren't able to accommodate change in position, even these minor changes in position.
As kids, we can practically sleep in any position we want. As we age, we find that we are less able to do so. We start to require certain pillows to sleep, mattresses that form to our body, etc. It's not your mattress that's the problem. And it's not your pillow. It's your body.
Many times we think of the spine as being composed of bones and discs, and we forget that there are multitudes of ligamentous attachments. Cells in these tissues sense tension, pressure, vibration, movement, and pain - they have neurosensory function! When stretched, these cells send signals. When injured, they send pain signals. When ligaments start to loose elasticity, they can't stretch as much. Think of it as a dried out rubber band - you stretch it and it breaks! These ligaments do too.
We can't stop our ligaments from losing elasticity over time, but we can slow down that process by adopting certain habits and avoiding behaviors that increase their decline
1. Avoid smoking.
2. Avoid alcohol.
3. Stay hydrated by drinking water, avoiding caffeine, and consuming moisture rich foods.
4. Eat foods high in antioxidants such as vegetables and fruits, like berries.
5. Move your body! Ligaments and joints need movement to stay healthy.
6. Improve circulation and movement through your spine by breathing with your diaphragm.
7. Get chiropractic care to make sure all the segments in your spine have healthy movement.
8. Do yoga and pilates to move, stabilize, and stretch your body.
9. Apply good, evenly applied stress to joints with weight lifting.
10. Avoid sitting and inactivity for long periods of time.
11. Reduce use of chemicals that can negatively impact ligaments such as corticosteroids and some antibiotics
12. Get a sufficient amounts of restful sleep at night.
13. Be intentional in reducing stress and stressful situations in your life.
14. When a ligamentous injury occurs, avoid using ice, seek treatment involving passive, active, and loaded movement.
15. Learn mindfulness and self awareness, and listen to your body when something doesn't seems right, don't ignore what your body is trying to tell you - address it.