While Kipling is known for his stories set in India, his work also includes stories set in the United States, but not in Gloucester. He did write a short story called "The Finest Story in the World," which features a character named "Cap'n" who lives in Gloucester, but that is not a novel.
Are you perhaps thinking of a different author or a different location?