Can I get a UK Tourist visa if my US visa has expired?

I’m a South Asian who is in the US on a student visa. My visa has expired, which means that I need to renew my visa in my home country before re-entry.

I might need to go to the UK for an exchange. Can I get a UK visa within the US, if my US visa has expired? My plan is to go to the UK, and from there fly to my home country to renew my student visa before coming back to the US.