[SOLVED] Prerender 504 (Gateway Timeout) & Cloudflare


I am trying to set up prerender (package dferber:prerender) but I am running into an issue.

On my local environment with a local prerender server running, it’s working fine. When I visit http://localhost:3000/?escaped_fragment= and check the page source code, I see that prerender is working.

However, when I try to use it with a token (i.e. omit serviceUrl in the settings.json file) I get a gateway timeout on localhost. On a deployed app, website.com/?_escaped_fragment_= there’s nothing happening, the home page is rendered and prerender is not doing anything.

Any ideas ?

Check your PreRender.io console, make sure your site is connecting to PreRender properly

How would I do that ? I think it’s not connected as the only cache miss I can see at https://prerender.io/crawl-stats are from localhost:3000

Ah I see, then you’re very likely not configured properly. Your pre render account should CLEARLY show you cached pages in your account when it works.

So if you’re not seeing anything, re-double check your project settings. Make sure your settings.json is correct, etc.

I cleared the cloudflare caches and I am now getting a 504. At least the request is going to prerender.io.

By checking their console:
504 Miss 1.362 s a few seconds ago Chrome 56.0

The URL does not seem valid, right ? Could it be cloudflare and their proxy or something ?

Okay cloud flare… that’s always a mess! Try by-passing by unclicking the orange icon. This goes right to your origin point, thus exposing and bypassing CloudFlare, but it removes that as part of your problem for now.

I’m running my game on CloudFlare with no issues remarkably.

So if you log in to PreRender, you should see a bucket load of caches made, and their big “WE DID NOT RECEIVE ANY REQUESTS YET” message is gone?

I unclicked the orange icon (now DNS only), but I am still seeing their error page when hitting https:/website.com/?escaped_fragment=

If I curl:

HTTP/1.1 504 Gateway Timeout
Server: nginx
Date: Fri, 12 May 2017 19:48:22 GMT
Content-Type: text/html;charset=UTF-8
Connection: keep-alive
x-powered-by: Express

At https://prerender.io/crawl-stats, I can see that they received a request but as I said in my previous update, the IP is not right.

Pretty sure it has something to do with nginx…

What’s your URL?

Ahh yes, Nginx… I was trying to get stuff working on Apache, then I build an Nginx server… what a friggin night mare.

Have you thought about trying Meteor Galaxy? It’s better…

Anyway. Lets see. Maybe Nginx is blocking something.

Soooo, Thanks to prerender.io support I figured it out.

I cleared Cloudflare caches, and then:

  prerenderio.set('prerenderToken', 'token');
  prerenderio.set('protocol', 'https');
  prerenderio.set('host', 'website.com');

Thanks @SkyRooms, your help is very much appreciated !

1 Like

Fantastic! Cheers and good luck.

1 Like

Thanks for the help @SkyRooms :smiley: You rock!

1 Like