What causes pain in the kidneys before passing urine?

Back pressure/reflux. Full distended bladder can be obstructive to passage of urine from the kidneys. Another explanation could be reflux of urine backwards from bladder to kidneys because of incompetent bladder valves. Suggest you consult your dr. Who might refer or order a renal & bladder ultrasound to include views with a full bladder followed by post-void views. This could give the answer.