# Youtube embeds missing

**URL:** https://meta.discourse.org/t/youtube-embeds-missing/47718
**Category:** Support
**Created:** [July 24, 2016, 3:50pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718 "2016-07-24T15:50:16Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 24, 2016, 3:50pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/1 "2016-07-24T15:50:16Z")

</div>

I have a client for whom embedded youtube videos are missing. They appear in composer’s preview, but when the messages are saved, they disappear. They are working fine in [try.discourse.org](http://try.discourse.org). I tried whitelisting youtu.be and changing the URL to a [youtube.com](http://youtube.com) url too. Neither solved the problem.

The site is running v1.6.0.beta11 +141

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [July 24, 2016, 9:23pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/2 "2016-07-24T21:23:49Z")

</div>

Have you tried reaching YouTube from your client’s server?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 25, 2016, 6:27pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/3 "2016-07-25T18:27:25Z")

</div>

It seems that the problem was that recent Discourse updates have caused my [DOI resolver plugin](https://github.com/pfaffman/discourse-doi-resolver/tree/40adb5cd89bda3a82bc1888d535dfdb4b8a7de70) to muck things up. (I disabled a couple other things too, but it was definitely some plugin. . . )

---

<div class="post-metadata">

### Author: ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)
#### Post date: [March 15, 2020, 6:37pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/4 "2020-03-15T18:37:23Z")

</div>

Has anyone got a problem when rebaking posts running into 429 Too Many Requests for [youtube.com](http://youtube.com)?

```
[1] pry(main)> posts = Post.where("raw like '%youtube%'").count
=> 5237

```

🤔

---

<div class="post-metadata">

### Author: ![md-misko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/md-misko/32/126315_2.png) [@md-misko](https://meta.discourse.org/u/md-misko)
#### Post date: [March 16, 2020, 6:40am UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/5 "2020-03-16T06:40:49Z")

</div>

I have encountered this too, it is a temporary IP ban (1h, I believe), and all youtube oneboxes fail for the rebaked posts during that time.

Perhaps there should be some mechanism implemented to prevent more than x requests to youtube per hour when rebaking?

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [May 23, 2020, 6:57pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/6 "2020-05-23T18:57:30Z")

</div>

> [@Overgrow](#):
>
> Has anyone got a problem when rebaking posts running into 429 Too Many Requests for [youtube.com](http://youtube.com)?

> [@md-misko](#):
>
> I have encountered this too, it is a temporary IP ban (1h, I believe), and all youtube oneboxes fail for the rebaked posts during that time.

Recently after a series of changes and upgrades to my Discourse Installation, only two things are missing. One is [not being able to rebuild the data container](https://meta.discourse.org/t/how-to-move-from-standalone-container-to-separate-web-and-data-containers/29413/67), and I’m trying to figure it out, but the other is that every onebox works except with YouTube URLs.

From inside the server and container I can CURL to YouTube, how can I make sure that it is due to temporary IP Ban?

**Edit** : Can confirm that neither Rebuild (App) nor Rebake affect this issue.

**Edit 2** : By searching I saw that @jomaxro commented [here](https://meta.discourse.org/t/onebox-not-working-after-discourse-upgrade/73223/7) that things like CloudFlare can affect Oneboxes… can a CDN affect just one Onebox? Tried putting it on Development Mode but no changes.

**Edit 3** : Tried removing all plugins. Nothing changed. (Also, I’m unable to rebake since it seems that processes cut each other).

**Edit 4** : Tried @Overgrow’s command and yep, indeed _I have a problem_

```
[1] pry(main)> posts = Post.where("raw like '%youtube%'").count
=> 72674

```

I’m having a hard time trying to run the rebake commands because my container is throwing me this:

`PG::UnableToSend: no connection to the server`

`PG::ConnectionBad: PQconsumeInput() SSL SYSCALL error: EOF detected`

Do I need to stop something?

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [May 25, 2020, 2:42pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/8 "2020-05-25T14:42:00Z")

</div>

One approach might be to simply rebake using a pattern match and set a delay.

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [May 25, 2020, 3:12pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/9 "2020-05-25T15:12:16Z")

</div>

Something like:

`rake posts:rebake_match["%youtube%",regex,10]`

?

My main issue is being unable to run the command 😓

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 25, 2020, 5:13pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/10 "2020-05-25T17:13:04Z")

</div>

> [@Iceman](#):
>
> `[1] pry(main)> posts = Post.where("raw like '%youtube%'").count`

This might work to slowly rebake: `Post.where("raw like '%youtube%'").where("cooked NOT LIKE '%lazyYT%'").update_all(baked_version: nil)`

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [May 25, 2020, 5:20pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/11 "2020-05-25T17:20:44Z")

</div>

First of all, thanks a million for taking time to help me @riking.

I ran that command and got what I assume is the number of posts missing: 22462. Based on the last part of the command, is safe to assume that it is running in the background?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 25, 2020, 5:25pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/12 "2020-05-25T17:25:32Z")

</div>

Yeah, there’s a job that runs every 15 minutes that will re-process `SiteSetting.rebake_old_posts_count` posts.

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [May 25, 2020, 8:18pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/13 "2020-05-25T20:18:02Z")

</div>

Just a question, the number won’t go down no matter how much time passed. Is there a way for me to either follow or force that job?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 25, 2020, 8:19pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/14 "2020-05-25T20:19:45Z")

</div>

Hmm, possible that I messed it up 🤔 What’s the result of this? `Post.where("raw like '%youtube%'").where("cooked LIKE '%lazyYT%'").count`

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [May 25, 2020, 8:23pm UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/15 "2020-05-25T20:23:46Z")

</div>

Current status:

Old Command:

```
[2] pry(main)> Post.where("raw like '%youtube%'").where("cooked NOT LIKE '%lazyYT%'").update_all(baked_version: nil)
=> 23257

```

New Command:

```
[1] pry(main)> Post.where("raw like '%youtube%'").where("cooked LIKE '%lazyYT%'").count
=> 49458

```

Edit: After some time I can confirm that the second one remains static (same value) while the first one keeps increasing.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [May 26, 2020, 4:29am UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/16 "2020-05-26T04:29:11Z")

</div>

> [@Iceman](#):
>
> Something like:
> 
> `rake posts:rebake_match["%youtube%",regex,10]`
> 
> ?
> 
> My main issue is being unable to run the command 😓

Regex is not required to match a string in a post. A simple string search will match `youtube` (for example) well enough. In this example, every post with the string `youtube` in the post will be rebaked, one per every 100 seconds (very slow…)

![Screen Shot 2020-05-26 at 11.23.06 AM](https://global.discourse-cdn.com/meta/optimized/3X/3/6/36a9b433a061c8ac8b53a3fba01ff5fd939d3200_2_690x46.jpeg)

Around 100 seconds passed:

![Screen Shot 2020-05-26 at 11.25.35 AM](https://global.discourse-cdn.com/meta/optimized/3X/5/1/51e9a0152ec5665a877c33d5fbb8abe487b94960_2_690x46.jpeg)

I will let this run, guessing that in 76,200 seconds, plus or minus, this rake task will be done 🙂

Guess I should have set this example to a 10 second delay 🙂

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [May 26, 2020, 9:53am UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/17 "2020-05-26T09:53:19Z")

</div>

Thank you very much @neounix

Tried it, but sadly without success.

I’m starting to believe that maybe there is something related to networking?

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [May 26, 2020, 10:00am UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/18 "2020-05-26T10:00:21Z")

</div>

> [@Iceman](#):
>
> Tried it, but sadly without success

Sorry @iceman,

Being a kind of nerdy guy, I don’t understand what “without success” means 🙂 (not enough tech info)

You mean when you run the rake command, you get a rails error?

If so, please post the full rails error.

Or, does the rails task execute OK? If so, how many posts were rebaked according to the rake task?

Thanks.

For example, my little (very slow 100 sec delay) sample rebake task (running, for this topic) as been running for hours:

![Screen Shot 2020-05-26 at 5.09.07 PM](https://global.discourse-cdn.com/meta/optimized/3X/e/9/e9bbdd7f3d5b91452c06ac773c2bd7d25db91b06_2_690x44.jpeg)

Currently 209 of 762 total…

What are your rebake task numbers?

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [May 26, 2020, 10:44am UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/19 "2020-05-26T10:44:37Z")

</div>

Pardon me on my poor info!

I meant that I ran it on a small sample and then re-ran it but the number didn’t change.

ie: I ran the command and I had 76000 posts, it baked 200, then stopped and ran another and the new number was 76200 (yes, maybe my users added 400 posts with YouTube on it… but…I don’t know).

Now I’m running it again just to see how it goes but it will take some days 😛 (76500 hits…)

Since no one else has this issue I’m trying to think on my variables and basically:

- Changed Machine (So it _could_ be YouTube rate limiting?)
- Restored a Discourse Backup on a new Install (this _shouldn’t_ be related, but at this point I’m betting on everything that moves)
- Two Container Installation (Thought I had an issue with the Data rebuild but [thanks to this info](https://meta.discourse.org/t/postgresql-12-update/151236/241) from @Falco now I know that it is “normal”.
- Put CloudFlare on top of it following the CDN Tutorials that are here.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [May 26, 2020, 10:53am UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/20 "2020-05-26T10:53:22Z")

</div>

> [@Iceman](#):
>
> ie: I ran the command and I had 76000 posts, it baked 200, then stopped and ran another and the new number was 76200 (yes, maybe my users added 400 posts with YouTube on it… but…I don’t know).

Sorry for having a thick skull 🙂 you mean you are running this rake task?

```plaintext
rake posts:rebake_match['youtube',string,10]

```

It is important to post exactly what you are typing and seeing.

What is the exact rake task, which parameters are you running?

When you run that rake task, what is the first few lines of output when the tasks starts to rebake?

Please post details, screen shots, copy-and-paste from your command line(s), etc.

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [May 26, 2020, 11:18am UTC](https://meta.discourse.org/t/youtube-embeds-missing/47718/21 "2020-05-26T11:18:47Z")

</div>

Sorry @neounix, you are 100% right.

Let me rephrase:

I ran this command:

```
root@cont-web-only:/var/www/discourse# time rake posts:rebake_match['youtube',string]
        76597 / 76594 (100.0%)-
    76597 posts done!

```

Then I was like “well, doh, you need to add the timer, otherwise we can’t test the “Rate Limit Theory””, so I tried the one you posted:

```
root@cont-web-only:/var/www/discourse# time rake posts:rebake_match['youtube',string,100]
            216 / 76594 (0.2%)-

```

And stopped it just to go check if things were changing. Apparently nothing, so I thought: “ok, let me run this again and see how it goes”:

```
root@cont-web-only:/var/www/discourse# time rake posts:rebake_match['youtube',string,100]
           116 / 76598 (0.2%)-

```

That’s running right now. So my argument was that the number of total posts didn’t go down with the other rebake. (I could be, and possibly am, wrong with this logic).

[Next page](https://meta.discourse.org/t/youtube-embeds-missing/47718.md?page=2)
