Focus is one of the most frustrating problems when shooting in the dark. The number of astrophotos ruined by poor focus is legion. Worse, the problem is often not found until afterwards, when hours of effort have been wasted. Very slight errors in focus can spoil an otherwise great photo.
Taking photos in the dark creates a situation where the normal solutions do not work… Autofocus simply will not operate without enough light. Taking the lens off and attaching the camera to a telescope results in a completely manual focus. Simply focusing through the viewfinder is not accurate enough.
The simplest method of focusing in the dark is to use the live view feature of the camera. By placing a bright star or distant streetlight in the view and magnifying you can achieve a reasonably good focus much of the time. This is not perfect, even the magnified image is a little mushy near ideal focus, making perfect focus difficult to judge. If you find yourself in an after-dark situation, without any special equipment along, this is the method to use.
Do remember to switch off the autofocus feature of your lens. Once you get focus set correctly you do not want to lose it the moment you touch the shutter button. Not that I have ever done that… Never? Well, perhaps maybe.