DEV Community

Cover image for Running Puppeteer on Heroku Free Tier

Posted on

Running Puppeteer on Heroku Free Tier

Heroku is my favorite cloud platform to host my apps.
During Covid-19 I created myself some cool automation(I'm working on another post on it) and was looking for a place to run it for free.

For example, notify me when my restaurant is open in Wolt.

So my requirement was:

  • Running puppeteer
  • Easy to create a scheduled task
  • Easy to deploy
  • Free

I have experience with Heroku, so it was my first choice.
The free tier is giving you more than 500h per month.

Easy to sync with my GitHub repo already integrated into Heroku.

Scheduled task - There is a simple addon named - Heroku Scheduler which allows you to run commands in scheduled time. Super easy to use, and doesn't require any additional runtime of the instance itself(so we're still in the free tier)

The biggest problem for me was to find the right configuration to run a puppeteer in Heroku.
BTW, if you don't know puppeteer yet. Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol.

I was looking at how to run it, but couldn't find a configuration that worked for me...

So, this is my configuration(it's not necessarily ideal, but it works)


JS code

const chromeOptions = {
    headless: true,
    defaultViewport: null,
    args: [
const browser = await puppeteer.launch(chromeOptions);
const page = await browser.newPage();
Enter fullscreen mode Exit fullscreen mode

Use the following flags when you launch puppeteer

  • "--incognito",
  • "--no-sandbox",
  • "--single-process",
  • "--no-zygote"

Feel free to read more about it...

I hope it solved your problem:)
Good luck

Discussion (3)

chan_austria777 profile image

any reason why you came up with those launch options? Can't find documentation about those.

ziv profile image
zivka Author

So regarding headless: true that's because it's running on a Linux without GUI,
defaultViewport: null is related to the width and height, it's not mandatory
--incognito was for my use(in order to start without any cookies and etc.
and regarding the last three args

Enter fullscreen mode Exit fullscreen mode

I'm not really sure, but that worked for me after a couple of tries...
Not sure what is running in Heroku that made this configuration worked for me:)

aurium profile image
Aur矇lio A. Heckert

--no-sandbox i believe it means all page related process in main thread.

--single-process means no parallelism for plugins and graphics.

--no-zygote no "main forker".

That all together enforces only one chromium process.