Raise the API Rate Limit for a Self-Hosted Instance of Plausible
Tags: analytics
Published: 2024-01-02 06:29:35

---
title: Raise the API Rate Limit for a Self-Hosted Instance of Plausible
published: true 
date: 2024-01-02 06:12:56 UTC
tags: analytics 
canonical_url: https://plausiblebootstrapper.com/posts/increase-plausible-rate-limits
---

I've been using the [self-hosted version](https://plausible.io/self-hosted-web-analytics?ref=alex-macarthur) of Plausible Analytics for a couple of years now, and [I've really enjoyed it](https://macarthur.me/posts/moving-from-google-analytics-to-plausible?ref=alex-macarthur). One of the many perks of the self-hosted model is that I'm able to do what I want with my data as often as I want to do it.

For example: this is statically generated site. Every time it builds, I pull in the latest analytics data from the Plausible REST API to render on various pages, including my [personal dashboard](https://macarthur.me/dashboard?ref=alex-macarthur). By default, there's a rate limit set in place – 600 requests/hour. That's usually a suitable default, but it's occasionally not.

Fortunately, being self-hosted, it's easy enough to raise that limit to something astronomical. Let's walk through it. Heads up: I'm assuming you're on a virtual machine that you can access via SSH (mine's on DigitalOcean).

## Accessing Plausible's Postgres Database

Access the machine and `cd` to wherever your instance of Plausible is living:

```
# replace with your VM's IP address:
ssh root@123.456.789.101

# replace with wherever your instance lives:
cd /opt/plausible
```

_.._

Next, we'll need to find the name of the container in which Plausible's Postgres database is running. Run `docker ps` and you'll see a list of running containers. You're looking for the name assigned to the one using the "postgres:VERSION" image:

![list of running containers](https://cms.macarthur.me/content/images/2024/01/image-4.png)

Now, we'll access that container with `psql`, logging in under the `postgres` user:

```
docker exec -ti plausible_plausible_db_1 psql -U postgres
```

Running `\l` should show every database running in the container:

![list of every database running in the Docker container](https://cms.macarthur.me/content/images/2024/01/image-1.png)

Run `\c plausible_db` to connect to the database we'll need:

![](https://cms.macarthur.me/content/images/2024/01/image-2.png)

We're in. Next up, let's find the table and raise that API limit.

### Raising the API Key Limit

The table we'll need to update is `api_keys`. Just for sanity's sake, go a head and view the records in there. Assuming you've already generated a token (if you haven't, do it), you'll see something similar to this:

![example of API key records](https://cms.macarthur.me/content/images/2024/01/image-3.png)

As might've guessed, we're interested in that `hourly_request_limit` field. That field is an `integer` type, which has a [maximum value](https://www.postgresql.org/docs/current/datatype-numeric.html?ref=alex-macarthur#DATATYPE-NUMERIC) of 2,147,483,647. So, let's update it:

```
UPDATE public.api_keys SET hourly_request_limit = 2147483647;
```

## You did it.

But before you move on, keep a couple of things in mind:

- This change won't impact any keys you add in the future. If you add any later, you'll need to run through this process again.
- There are reasons rate limits exist in the first place. You're virtually removing it here, so think about the potential performance and security implications of that decision. 

Hope this is useful to someone!