Your problem can be due to any reason like dysfunctional voiding , inflammation of the prostate, uti etc. All these needs to be evaluated systematically to establish the reason for your discomfort.
Next Steps
consult an Urologist for proper evaluation and management
Health Tips
drink less of tea/ coffee/ have less spicy food. stop drinking water atleast 1 hour prior to sleeping and urinate immediately before going to sleep.