Cannot embed YouTube videos “Failed to embed” error

This may be due to a failed network request from the server to youtube. If the server cannot reach YouTube, the embed will show as “failed to embed” in the editor.

You can fix the problem by allowing the server to make network requests to youtube.

The WordPress Proxy documentation may be helpful, https://developer.wordpress.org/reference/classes/wp_http_proxy/

WordPress core code –

https://github.com/WordPress/WordPress/blob/master/wp-includes/class-oembed.php#L362-L364
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-oembed.php#L457-L480