For Canada go here. For the USA, go here. If you do not qualify for an electronic Visa, you will need to contact the consulate for advice. Even if you are only transiting The USA or Canada, you are required to have a visa. Most people can apply for an online Visa/ESTA please apply at least 7 days prior to travel date. NO SAME DAY ESTA APPLICATIONS ARE PERMITTED.
If you do not qualify for an electronic Visa, you will need to contact the consulate for advice. Even if you are only transiting through the USA or Canada, you are required to have a visa. Most people can apply for an online visa.