Table of Contents

WordPress Embedded Youtube not Working on your WordPress Hosting ?

we have been getting request that certain Hosting / IP regardless dedicated box / vps or shared hosting , having failed YOUTUBE embedded issues

WordPress Embedded Youtube not Working on your WordPress Hosting ? 1
WordPress Embedded Youtube not Working on your WordPress Hosting ? 4

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

WordPress Embedded Youtube not Working on your WordPress Hosting ? 2
WordPress Embedded Youtube not Working on your WordPress Hosting ? 5

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

WordPress Embedded Youtube not Working on your WordPress Hosting ? 3
WordPress Embedded Youtube not Working on your WordPress Hosting ? 6

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&amp;q=EhAkAIkBAAAAAPA8kf_-a-hKGNebgPEFIhkA8aeDSwte-6MM4eyZ6juxpMMh1zhukRCrMgFy">here</A>.
</BODY></HTML>

302 Moved

The document has moved
here.

Table of Contents