Your ship will refuel if it is docked. It takes 4 hours to fill up the tanks.
Your ship will also refuel if it is at anchor. However, you can only anchor in shallow waters close to shore so make sure you don't run out in the middle of the ocean.
When on anchor you need to wait 4 hours before a refuel ship reaches you and another 4 hours to fill up te tanks.
So, when anchored overnight you should find your ship refueled the next morning.