Pain in back

I went to the er for back pain because I thought I had a kidney infection or appendicitis and turns out I pulled a muscle in my back 😩 I can’t even lay down to sleep. Has anyone else done this while pregnant before ??? How long till it got better and what helped