# How to get build failure notifications in Replit

- Tool: Replit
- Difficulty: Beginner
- Time required: 20-30 minutes
- Compatibility: All Replit plans. Webhook notifications require an Autoscale or Reserved VM deployment. Slack/Discord webhooks are free.
- Last updated: March 2026

## TL;DR

Replit does not have built-in push notifications for build failures, but you can set up alerts by checking deployment logs in the Deployments pane, creating a webhook-based notification system using a Replit Edge Function that posts to Slack or Discord when a build fails, and using a scheduled health check Repl that pings your deployed app and alerts you when it goes down.

## Get Notified When Your Replit Builds Fail

When a deployment build fails, you want to know immediately — not hours later when a user reports the issue. This tutorial shows you three approaches to build failure monitoring in Replit: checking deployment logs manually, setting up automatic Slack or Discord webhook notifications triggered by your build script, and creating a health check monitor that alerts you when your deployed app stops responding.

## Before you start

- A Replit account on any plan (Core or Pro recommended for deployments)
- A deployed Replit App (Autoscale or Reserved VM)
- A Slack workspace or Discord server for receiving notifications
- A Slack incoming webhook URL or Discord webhook URL

## Step-by-step guide

### 1. Check deployment logs in the Deployments pane

The first step is knowing where to look when a build fails. Open the Deployments pane from the left sidebar or by clicking the deploy/publish icon. Click the Logs tab to see real-time output from your deployment, including build step output, startup messages, and runtime errors. When a deployment fails, the Logs tab shows the exact error message and the build step that caused the failure. This is your manual monitoring baseline before setting up automated notifications.

**Expected result:** You can see deployment logs with build output, error messages, and timestamps in the Deployments pane Logs tab.

### 2. Create a Slack or Discord webhook URL

Before building the notification script, you need a webhook URL that accepts incoming messages. For Slack, go to api.slack.com/apps, create a new app, enable Incoming Webhooks, and copy the webhook URL. For Discord, right-click a channel, select Edit Channel, go to Integrations, click Webhooks, create a new webhook, and copy the URL. The webhook URL is a secret — you will store it securely in the next step.

**Expected result:** You have a webhook URL that can receive POST requests and display messages in your Slack channel or Discord channel.

### 3. Store the webhook URL in Replit Secrets

Open the Tools dock on the left sidebar and click Secrets (or search for 'Secrets' in the search bar). Add a new secret with the key SLACK_WEBHOOK_URL (or DISCORD_WEBHOOK_URL) and paste your webhook URL as the value. Secrets are encrypted with AES-256 and are available to your code via process.env. Never hardcode webhook URLs in your source code.

**Expected result:** The webhook URL is stored securely in Secrets and accessible in your code via process.env.SLACK_WEBHOOK_URL.

### 4. Create a notification script for build failures

Create a file called notify.js in your project root. This script sends a formatted message to Slack or Discord when called. You will wire this into your build pipeline so it triggers only when a build step fails. The script reads the webhook URL from Secrets and sends a POST request with the error details. For Discord, the payload format uses 'content' instead of 'text'.

```
// notify.js — sends build failure alerts to Slack or Discord
const SLACK_URL = process.env.SLACK_WEBHOOK_URL;
const DISCORD_URL = process.env.DISCORD_WEBHOOK_URL;

async function sendAlert(message) {
  const url = SLACK_URL || DISCORD_URL;
  if (!url) {
    console.error('No webhook URL configured in Secrets');
    return;
  }

  const isDiscord = url.includes('discord.com');
  const payload = isDiscord
    ? { content: message }
    : { text: message };

  try {
    const res = await fetch(url, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(payload),
    });
    if (!res.ok) console.error('Webhook failed:', res.status);
  } catch (err) {
    console.error('Failed to send alert:', err.message);
  }
}

const errorMessage = process.argv[2] || 'Build failed — check deployment logs';
const appName = process.env.REPL_SLUG || 'Unknown App';
sendAlert(`Build failure in ${appName}: ${errorMessage}`);
```

**Expected result:** Running 'node notify.js "TypeScript compilation failed"' in Shell sends an alert message to your Slack or Discord channel.

### 5. Wire the notification script into your build pipeline

Update your build script in package.json to call the notification script when any step fails. The || operator (OR) runs the next command only if the previous one fails — the opposite of && (AND). This way, the notification fires only on failure, not on success. The build still exits with a non-zero code so the deployment is properly aborted.

```
{
  "scripts": {
    "build": "npm run compile && npm run test",
    "compile": "tsc || (node notify.js 'TypeScript compilation failed' && exit 1)",
    "test": "jest || (node notify.js 'Tests failed' && exit 1)",
    "start": "node dist/index.js"
  }
}
```

**Expected result:** When a build step fails, a notification is sent to Slack or Discord with the specific failure reason. The deployment is still aborted due to the non-zero exit code.

### 6. Create a health check monitor with Scheduled Deployments

For ongoing monitoring of your deployed app, create a separate Repl that pings your app's health endpoint on a schedule and sends an alert if the app is down. Use Replit's Scheduled Deployment feature to run this monitor every few minutes. Create a new Repl, add the health check script below, and deploy it as a Scheduled Deployment with a schedule like 'Every 5 minutes'. Store both the app URL and webhook URL in the new Repl's Secrets.

```
// health-check.js — monitors your deployed app
const APP_URL = process.env.APP_URL;
const SLACK_URL = process.env.SLACK_WEBHOOK_URL;

async function checkHealth() {
  try {
    const res = await fetch(`${APP_URL}/health`, {
      signal: AbortSignal.timeout(5000),
    });
    if (!res.ok) {
      await notify(`App returned ${res.status} — may be down`);
    } else {
      console.log('Health check passed');
    }
  } catch (err) {
    await notify(`App unreachable: ${err.message}`);
  }
}

async function notify(message) {
  if (!SLACK_URL) return;
  await fetch(SLACK_URL, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ text: `Health Alert: ${message}` }),
  });
}

checkHealth();
```

**Expected result:** The health check runs on schedule. If your app is down or returns an error, you receive a Slack or Discord notification within minutes.

## Complete code example

File: `notify.js`

```javascript
/**
 * Build failure notification script
 * Sends alerts to Slack or Discord via webhooks
 *
 * Usage: node notify.js "Error description here"
 *
 * Required Secrets:
 *   SLACK_WEBHOOK_URL or DISCORD_WEBHOOK_URL
 */

const SLACK_URL = process.env.SLACK_WEBHOOK_URL;
const DISCORD_URL = process.env.DISCORD_WEBHOOK_URL;

async function sendAlert(message) {
  const url = SLACK_URL || DISCORD_URL;
  if (!url) {
    console.error('No webhook URL found. Add SLACK_WEBHOOK_URL or DISCORD_WEBHOOK_URL to Secrets.');
    process.exit(0);
  }

  const isDiscord = url.includes('discord.com');
  const payload = isDiscord
    ? { content: message }
    : { text: message };

  try {
    const res = await fetch(url, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(payload),
    });

    if (res.ok) {
      console.log('Alert sent successfully');
    } else {
      console.error(`Webhook returned ${res.status}`);
    }
  } catch (err) {
    console.error('Failed to send alert:', err.message);
  }
}

const errorMessage = process.argv[2] || 'Build failed';
const appName = process.env.REPL_SLUG || 'Unknown App';
const timestamp = new Date().toISOString();

sendAlert(`[${timestamp}] Build failure in *${appName}*: ${errorMessage}`);
```

## Common mistakes

- **Hardcoding the webhook URL directly in the notification script** — undefined Fix: Store the URL in Tools > Secrets as SLACK_WEBHOOK_URL or DISCORD_WEBHOOK_URL. Access it via process.env in your code.
- **Forgetting to add 'exit 1' after sending the notification, causing the build to succeed despite the failure** — undefined Fix: Always include 'exit 1' after the notification call: 'tsc || (node notify.js "compile failed" && exit 1)'. This ensures the deployment is properly aborted.
- **Not adding the webhook secret to the Deployments pane, so notifications work in development but not during actual deployments** — undefined Fix: Open the Deployments pane, go to Settings, and add SLACK_WEBHOOK_URL as a deployment secret. Workspace secrets do not carry to deployments.
- **Using the Discord webhook payload format for Slack or vice versa** — undefined Fix: Slack uses {"text": "message"} while Discord uses {"content": "message"}. The notification script should detect the URL format and use the correct payload.

## Best practices

- Always store webhook URLs in Replit Secrets — never hardcode them in source files
- Use the || operator in build scripts to trigger notifications only on failure
- Include the app name and timestamp in alert messages for easy identification
- Create a dedicated notification channel (#build-alerts) to avoid flooding general channels
- Set up a separate health check Repl with Scheduled Deployments for continuous monitoring
- Add deployment secrets separately from workspace secrets — they do not carry over automatically
- Use AbortSignal.timeout() in health checks to avoid hanging on unresponsive apps
- Test your notification script manually from Shell before wiring it into the build pipeline

## Frequently asked questions

### Does Replit have built-in build failure notifications?

No. As of March 2026, Replit does not offer push notifications for build or deployment failures. You can check the Logs tab in the Deployments pane manually, or build a webhook-based notification system as described in this tutorial.

### Can I send notifications to Discord instead of Slack?

Yes. Discord supports incoming webhooks similarly to Slack. The only difference is the payload format: Discord uses {"content": "message"} while Slack uses {"text": "message"}. Store the Discord webhook URL in Secrets as DISCORD_WEBHOOK_URL.

### How much does the health check monitor cost?

Scheduled Deployments cost $1/month base fee plus $0.000061/second of compute time. A health check running every 5 minutes that completes in under a second costs less than $1/month total.

### Can I get email notifications instead of Slack?

Replit does not have built-in email notifications. You can modify the notify.js script to call an email API like SendGrid or Mailgun instead of a Slack webhook. Store the API key in Secrets.

### Will notifications work during deployment builds?

Yes, but only if you add the webhook URL secret to the Deployments pane under Settings. Workspace secrets are not available during deployment builds.

### Can Replit Agent set up build notifications for me?

Yes. Prompt Agent v4: 'Create a notification script that sends Slack alerts when builds fail. Store the webhook URL in Secrets as SLACK_WEBHOOK_URL. Wire it into the package.json build scripts with the || operator.' Agent will create the script and update your configuration.

### How do I test the notification script without breaking a real build?

Run the script directly from Shell: 'node notify.js "Test notification"'. This sends a test message to your Slack or Discord channel without affecting any build process.

### What if I need more advanced monitoring with dashboards and incident management?

For production applications that need uptime dashboards, incident response workflows, and multi-channel alerting, consider tools like UptimeRobot or Better Stack. The RapidDev team can help integrate professional monitoring solutions with your Replit deployments.

---

Source: https://www.rapidevelopers.com/replit-tutorial/how-to-set-up-real-time-notifications-for-build-failures-on-replit
© RapidDev — https://www.rapidevelopers.com/replit-tutorial/how-to-set-up-real-time-notifications-for-build-failures-on-replit
