Overseas visitors are some times entitled to free treatment and some times have to pay.
It is up to the GP or Dentist whether to accept you onto their list of NHS patients. They may accept you on their list if you are living in the UK, but they don't have to.
Visitors are not usually entitled to get non-hospital treatment. For example, if you used to live in the UK and then went to live abroad, you wouldn't normally get free treatment if you came back for a visit. There are some exceptions to these rules, for example, if you need emergency treatment, contraception or attending Walk in Centres.
A GP may, in practice, be flexible in deciding whether you are resident in the UK, in order to qualify for free treatment. You will usually have to show that your stay in the UK has some degree of permanence and stability.
If you are a visitor in the UK for less than three months, a GP may accept you as a temporary resident. Otherwise, a GP may offer to accept you as a private patient and you will have to pay for treatment.
You may have difficulty finding a GP or a Dentist who is prepared to register you. In this situation you should contact your Clinical Commissioning Group or Local Health Board. In England and Wales, you can also get help to find a Doctor from NHS 111 on 111. In Scotland, you can contact NHS 24 on 0845 424 2424. In Northern Ireland, you should contact the Central Services Agency on 028 9032 4431.
Even if you are accepted onto a GP or Dentist's list of NHS patients, you have to pay charges for some things like prescription charges and dental treatment.
For more information about charges and the help you might get to pay for them, see Help with health costs.