Eligibility
To apply you must be living in the UK because of one of the following:
...
you have permission to stay (known as ‘leave to remain’) or are settled in the UK (known as ‘indefinite leave to remain’), but you cannot get a passport or travel document from your country’s national authorities
You must be in the UK when you apply.