Prince Rupert, British Columbia is the northernmost and closest rail-accessible Canadian city to Alaska. Prince Rupert is part of the Prince Rupert - Jasper section of Via Rail's service. To reach Jasper--which is a beautiful town in the Alberta Rocky Mountains--you need to begin in either Vancouver or Toronto; both cities offer rail connections from the US.
From Prince Rupert, things get a bit tricky. There are no rail connections with Northern Alaska, nor with with Canada's Yukon territory. There are flight-less options, including ferries run by the National Highway System, which can carry you from Prince Rupert to Skagway, Alaska.
Now in Skagway, you can cross back into Canada on one of the world's most scenic train routes: the White Pass and Yukon Route. This restore railway follows the Gold Rush path through the mountains.
From here, you'll need wheels to reach farther into Alaska. Consider renting a car in Carcross or nearby Whitehorse; follow Route 1 to Fairbanks. Further train travel exists from Fairbanks south to Anchorage.