If your chain has a reusable connector, your best bet is to remove it. Put it in an old coffee can, pour in some mineral spirits (petroleum distillate, nor the new "green" water based substitute), soak it a while then swish it around. Pour off the solvent into a glass jar to settle for future use, add fresh and repeat. Do this 3-5 times until the solvent stays pretty clean. Allow the chain to dry completely (overnight is a warm place is best), then oil with your favorite stuff.
You can do a similar job on the bike using one of those chain washer devices (not a fan). But the process is the same, keep chainging solvent until it stays clean ensuring that all grit is flushed from the inside. Actually it'll probably never et perfectly clean, so you can quit when very little untra fine stiff flushes out (usually 3-5 rinses).
If you use a chain washer on the bike, remove the wheel and put an axle or one of those chain keeper pulleys in it's place so you don't make a mess of the cassette and wheel. While you're at it, remove and wash the cassette too, the same way, or dry clean it using a strip of rag between the sprockets.
There are also self cleaning lubes with solvent inside, but I find they wash as much grit into the chain as out, and are an expensive way to do the job.
BTW- just like with chain lube, there is more than one way to skin a cat, and you'll get numerous opinions, passionately claiming to be the best. Read them all, form your own conclusions, and do whatever makes the most sense for you.
__________________
FB
Chain-L site
An ounce of diagnosis is worth a pound of cure.
Just because I'm tired of arguing, doesn't mean you're right.
“One accurate measurement is worth a thousand expert opinions” - Adm Grace Murray Hopper - USN
WARNING, I'm from New York. Thin skinned people should maintain safe distance.