One of the reasons Wi-Fi keeps disconnecting on your iPhone when locked may be that the router firmware is outdated. In this case, you should update it. In other cases, the tips mentioned above will help check why Wi-Fi keeps disconnecting on your iPhone when locked and correct the issue.