Keelung has a reputation as the rainiest city in Taiwan, and it earns it. The northeast monsoon brings persistent drizzle and overcast skies from October through March. Spring and early summer — April to June — offer the best combination of warmth and drier weather, though there are no guarantees. July and August are hot and humid, with occasional typhoons; September is typhoon season's tail end.
The rain, honestly, does not ruin a visit. The night market operates regardless of weather. The temples and caves are sheltered. The harbour looks atmospheric in mist. Bring a waterproof layer whatever the season and do not plan an itinerary that depends on clear skies.
Ghost Festival: Keelung's Ghost Festival in the seventh lunar month (typically August) is one of the largest and most elaborate in Taiwan. The city hosts water lantern ceremonies, elaborate public rituals, and processions that run for weeks. If you have any interest in Taiwanese folk religion or want to see a genuine community festival rather than a tourist event, this is the time to visit. Accommodation books up — plan ahead.
Weekdays vs. weekends: Keelung is a popular Taipei day-trip destination, and the night market and seafood restaurants fill up considerably on weekend evenings. Visiting on a weekday is quieter and less crowded at all the main sights.