title: Puppeteer doesn't work at VPS (DigitalOcean)
body: <p>I'm in a droplet at <a href="https://www.digitalocean.com/" rel="nofollow noreferrer">DigitalOcean</a> and i'm getting this error.</p>
  
  <pre><code>(node:5549) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 300000ms exceeded
      at Promise.then (/var/www/screenshot/node_modules/puppeteer/lib/NavigatorWatcher.js:94:
      at &lt;anonymous&gt;
  </code></pre>
  
  <p>The url that I'm trying to screenshot is <a href="https://www.pontofrio.com.br/" rel="nofollow noreferrer">https://www.pontofrio.com.br/</a></p>
  
  <p>I added an user agent to bypass the protection against headless request.</p>
  
  <p><strong>It worked in my local machine</strong> but when I run at my VPS it get the error, even if I increase the timeout value.</p>
  
  <p>I'm testing with postman.</p>
  
  <p>Local Machine Windows 8.1 x64 - Working</p>
  
  <p>Virtual Machine Linux 16.04 x64 - Working</p>
  
  <p>VPS Linux 16.04 x64 - Failing</p>
  
  <p>Here's the code</p>
  
  <pre><code>const bodyParser = require('body-parser');
  const cors = require('cors');
  const express = require('express');
  const fs = require('fs');
  const mkdirp = require('mkdirp');
  const path = require('path');
  const puppeteer = require('puppeteer');
  
  const PORT = 5005;
  const userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3542.0 Safari/537.36';
  
  express()
      .use(cors())
      // parse application/x-www-form-urlencoded
      .use(bodyParser.urlencoded({ extended: true }))
      // parse application/json
      .use(bodyParser.json())
      .post('/screenshot', (req, res) =&gt; {
          let result;
          const filename = req.body.filename;
          const filepath = path.join(__dirname, 'images');
          const url = req.body.url;
          const wdt = req.body.width || 1366;
          const hgt = req.body.height || 768;
  
          if (!fs.existsSync(filepath)) mkdirp.sync(filepath);
  
          (async () =&gt; {
              const browser = await puppeteer.launch({
                  executablePath: '/opt/google/chrome/chrome',
                  args: [
                      '--disable-setuid-sandbox',
                      '--disable-gpu',
                      '--no-first-run',
                      '--no-sandbox',
                  ]
              });
              const page = await browser.newPage();
  
              await page.setUserAgent(userAgent);
  
              await page.goto(url, { waitUntil: 'networkidle2', timeout: 300000 });
              await page.setViewport({ width: parseInt(wdt), height: parseInt(hgt) });
              await page.screenshot({ path: `${filepath}/${filename}.jpg` });
  
              await browser.close();
  
              if (fs.existsSync(path.join(`${filepath}/${filename}.jpg`))) {
                  result = `Imagem salva em: ${filepath}/${filename}.jpg`;
              } else {
                  result = 'Erro ao salvar imagem, tente novamente.';
              }
  
              res.send(result);
          })();
      })
      .use('/screenshot', express.static((path.join(__dirname, '/images'))))
      .listen(PORT, () =&gt; console.log(`Rodando na porta ${PORT}`));
  </code></pre>