we have been getting request that certain Hosting / IP regardless dedicated box / vps or shared hosting , having failed YOUTUBE embedded issues
This will happen as youtube is blocking suspicious IP that trying to get data (those trying to download youtube videos and etc) and while this is happening , your hosting company’s data center might be targeted and blocked. The symptom ? Intermittently cannot embedded youtube video or totally cannot embedded
for WordPress , please try to add this Workaround code, it may be able to help you
go to appearance > theme editor
add the following code at the end of your File: functions.php
add_action( 'http_api_curl', function( $curl_handle ) {
curl_setopt( $curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
});
Apparently , Youtube block mostly IPV6 so the code will force a IPV4 connection so you can get a preview during embedded posting
Example like this
you should be able to embedded youtube again Do try it out
There are other method to confirm if your IP/Server getting block is by running a CURL command through your SSH
curl https://www.youtube.com/watch?v=3q6D0wMX_H0
You will get below
curl https://www.youtube.com/watch?v=3q6D0wMX_H0
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="https://www.google.com/sorry/index?continue=https://www.youtube.com/watch%3Fv%3D3q6D0wMX_H0&q=EhAkAIkBAAAAAPA8kf_-a-hKGNebgPEFIhkA8aeDSwte-6MM4eyZ6juxpMMh1zhukRCrMgFy">here</A>.
</BODY></HTML>
302 Moved
The document has moved
here.