Pilot conducting a night VFR flight reported they had to take evasive action to avoid high terrain while descending to enter the pattern at pattern altitude.
Synopsis
Pilot conducting a night VFR flight reported they had to take evasive action to avoid high terrain while descending to enter the pattern at pattern altitude.
Narrative
I was approaching to land at ZZZ; an airport I have flown to only during the day a few times; from the Southeast on a night with a Waxing Crescent moon. Not much moonlight being available. The course that I previously plotted for entering the airspace heading to the airport on Foreflight was close to directly over ZZZ1. This was purposely chosen to avoid the high terrain close to the 130 radial from ZZZ2 that I noted during planning. Once I made contact with the Tower frequency; I was instructed to enter a right base for Runway XXR. I had a descent rate that allowed me to get fairly close to the pattern altitude as I was entering the airspace; which put me on a collision course with the high terrain. I did not notice it in the moment; as I was scanning outside for traffic and beginning to prepare the aircraft to land. As I was scanning outside; I noticed that I was beginning to lose sight of the south part of the Airport. I moved my eyes around a bit more; and could just faintly see the outline of a dark mountain in front of me (which ended up being about a mile and a half out in front). I quickly applied full power and banked slightly right to change my course; which was more than enough to almost immediately regain sight of the Airport and avoid the terrain.I did notice that this dark terrain was close to the horizontal path of Runway XY; which could be dangerous for VFR aircraft approaching the airport from this direction too. I was able to get back on base and make a normal landing. There are many small things that led up to this situation occurring. I did correctly note this high terrain in preflight planning; but I personally failed to keep it in mind as I was preparing to land and could not easily visually see it until I was very close to it. This situation could have been fully avoided by flying in to the airport airspace from around the 080 to 100 radials; or even from a more northern course. I could have also planned to reach pattern altitude closer to the airport; rather than aiming to be at it upon entry to the airspace (unlike what I have been used to with airports that have usually flat terrain around them). From what I remember; the obstacle database in this airplane has not been updated in a long time. However; having the top of the terrain lit up somehow could have also greatly helped in avoiding it from afar visually in very dark conditions such as this night. I have personally learned a lot from this situation with pre-flight planning along with noting obstacles along the way (visually seen and checking all tools available to make sure I am clear on my path in conditions where I may not be able to see as well). I will now consider filing instrument flight plans or just simply not fly in dark conditions to destinations within mountainous terrain areas to totally avoid situations like this.
Source: NASA Aviation Safety Reporting System (public domain). Reports are voluntary submissions and are not verified by NASA.