How to Add Multiple Mastodon Relays Without Duplicating Posts
🔍 WiseChecker

How to Add Multiple Mastodon Relays Without Duplicating Posts

When you run a small Mastodon server, relays pull in public posts from other instances so your local timeline stays active. Adding multiple relays can flood your timeline with duplicate content if the same post arrives from two different relays. This happens because relays often share overlapping subscriptions and push identical posts to your instance. In this article, you will learn how to configure multiple relays on your Mastodon server and prevent duplicate posts from appearing in your federated timeline.

Key Takeaways: Mastodon Relay Configuration Without Duplicates

  • Mastodon Relay API endpoint: Each relay has a unique inbox URL that your instance subscribes to for receiving public posts.
  • Deduplication by ActivityPub ID: Mastodon automatically discards duplicate posts that share the same ActivityPub object ID, regardless of which relay delivered them.
  • Relay list in Admin > Relays: Add multiple relays here; Mastodon handles deduplication server-side so you do not need extra tools.

ADVERTISEMENT

How Mastodon Relays Work and Why Duplicates Happen

A Mastodon relay is a special server that collects public posts from many instances and redistributes them to all subscribed instances. When you add a relay, your server sends a subscription request to that relay’s inbox URL. The relay then pushes every public post it receives to your server’s inbox.

Duplicates occur when two relays both subscribe to the same source instance. For example, Relay A and Relay B both subscribe to instance example.social. A user on example.social posts a public toot. Relay A and Relay B both receive that toot and both push it to your server. Without deduplication, the same post would appear twice in your federated timeline.

Mastodon uses the ActivityPub protocol, which assigns a unique id field to every post. This id is a URI like https://example.social/users/1/statuses/12345. When your server receives an incoming activity, it checks whether a post with that id already exists in the local database. If it does, the duplicate is silently ignored. This mechanism works regardless of how many relays deliver the same post.

The deduplication check happens at the database level. Mastodon’s Status model has a unique index on the uri column, which stores the ActivityPub id. Attempting to insert a second record with the same uri causes a database constraint violation, and Mastodon catches that error and discards the duplicate. This means you can safely add any number of relays without timeline clutter.

What to Check Before Adding Multiple Relays

Deduplication works automatically, but you should verify a few settings to avoid performance issues. Each relay adds network traffic and processing load. If your server has limited resources, too many relays can slow down incoming activity processing. Also ensure your server’s database is properly indexed. The default Mastodon installation creates the necessary indexes, but custom deployments may have missed them.

Steps to Add Multiple Relays in Mastodon Admin Panel

  1. Log in as an admin
    Open your Mastodon instance in a web browser. Log in with an account that has administrator privileges. Only admins can add or remove relays.
  2. Navigate to Server Settings > Relays
    Click the gear icon in the top right corner to open Server Settings. In the left sidebar, click Relays. This page shows all currently subscribed relays and their status.
  3. Obtain the relay inbox URL
    Each relay has a public inbox URL. For example, the relay operated by mastodon-relay.example.com typically has an inbox URL like https://mastodon-relay.example.com/inbox. Check the relay’s documentation or contact the relay operator for the correct URL.
  4. Click Add New Relay
    On the Relays page, click the Add New Relay button. A text field appears where you paste the relay inbox URL.
  5. Paste the relay URL and click Add
    Copy the inbox URL from the relay provider. Paste it into the text field. Click Add. Mastodon sends a subscription request to that relay. The relay must accept the request before posts start flowing.
  6. Wait for the relay to accept
    After adding a relay, its status shows as Pending. Most relays automatically accept subscription requests within a few minutes. If the status stays Pending for more than an hour, the relay operator may need to approve your instance manually. Refresh the Relays page to see the status change to Working.
  7. Repeat for each additional relay
    Click Add New Relay again and enter the next relay inbox URL. You can add as many relays as you want. Mastodon handles deduplication as described earlier.

ADVERTISEMENT

What to Avoid When Adding Multiple Relays

Adding the same relay twice

If you accidentally subscribe to the same relay twice, Mastodon may display an error because the subscription already exists. The admin panel usually prevents duplicate subscriptions. If you see an error, check your current relay list and remove any duplicates.

Using untrusted or malicious relays

A relay can push any content to your instance, including spam or illegal material. Only add relays operated by known and reputable organizations. The official Mastodon relay list on joinmastodon.org is a good starting point.

Overloading your server with too many relays

Each relay sends a continuous stream of posts. If your server has limited CPU or memory, adding ten or more relays can cause delays in processing incoming activities. Monitor your server’s resource usage after adding relays. If you notice slowdowns, remove the least useful relays.

Expecting relays to work with private posts

Relays only distribute public posts. Private or followers-only posts are never shared through a relay. Deduplication does not apply to private posts because they are not delivered via relays at all.

Mastodon Relay vs Direct Instance Subscription: Deduplication Handling

Item Relay Subscription Direct Instance Subscription
Delivery method Relay pushes posts to your server Your server pulls posts from remote instance
Duplicate risk High when using multiple relays with overlapping sources Low; only one source instance per subscription
Deduplication mechanism Automatic via ActivityPub ID uniqueness Automatic via ActivityPub ID uniqueness
Performance impact Higher due to constant push traffic Lower; traffic is on-demand
Admin effort to add Paste one URL per relay Must discover and follow individual instances

You can now add multiple relays to your Mastodon instance without worrying about duplicate posts. The built-in deduplication system uses the ActivityPub id field to discard identical posts regardless of how many relays deliver them. Start by adding two or three relays from the official Mastodon relay list. Monitor your server’s performance and remove any relay that does not provide useful content. For advanced control, you can also set up your own relay and configure it to only forward posts from specific instances.

ADVERTISEMENT