Skip to main content
RapidDev - Software Development Agency
replit-tutorial

How to get build failure notifications in Replit

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.

What you'll learn

  • Navigate the Deployments pane to check build and deployment logs
  • Create a notification script that posts to Slack or Discord when a build fails
  • Set up a health check monitor using a Scheduled Deployment
  • Configure webhook URLs securely using Replit Secrets
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner8 min read20-30 minutesAll Replit plans. Webhook notifications require an Autoscale or Reserved VM deployment. Slack/Discord webhooks are free.March 2026RapidDev Engineering Team
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.

Prerequisites

  • 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'.

typescript
1// notify.js — sends build failure alerts to Slack or Discord
2const SLACK_URL = process.env.SLACK_WEBHOOK_URL;
3const DISCORD_URL = process.env.DISCORD_WEBHOOK_URL;
4
5async function sendAlert(message) {
6 const url = SLACK_URL || DISCORD_URL;
7 if (!url) {
8 console.error('No webhook URL configured in Secrets');
9 return;
10 }
11
12 const isDiscord = url.includes('discord.com');
13 const payload = isDiscord
14 ? { content: message }
15 : { text: message };
16
17 try {
18 const res = await fetch(url, {
19 method: 'POST',
20 headers: { 'Content-Type': 'application/json' },
21 body: JSON.stringify(payload),
22 });
23 if (!res.ok) console.error('Webhook failed:', res.status);
24 } catch (err) {
25 console.error('Failed to send alert:', err.message);
26 }
27}
28
29const errorMessage = process.argv[2] || 'Build failed — check deployment logs';
30const appName = process.env.REPL_SLUG || 'Unknown App';
31sendAlert(`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.

typescript
1{
2 "scripts": {
3 "build": "npm run compile && npm run test",
4 "compile": "tsc || (node notify.js 'TypeScript compilation failed' && exit 1)",
5 "test": "jest || (node notify.js 'Tests failed' && exit 1)",
6 "start": "node dist/index.js"
7 }
8}

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.

typescript
1// health-check.js — monitors your deployed app
2const APP_URL = process.env.APP_URL;
3const SLACK_URL = process.env.SLACK_WEBHOOK_URL;
4
5async function checkHealth() {
6 try {
7 const res = await fetch(`${APP_URL}/health`, {
8 signal: AbortSignal.timeout(5000),
9 });
10 if (!res.ok) {
11 await notify(`App returned ${res.status} — may be down`);
12 } else {
13 console.log('Health check passed');
14 }
15 } catch (err) {
16 await notify(`App unreachable: ${err.message}`);
17 }
18}
19
20async function notify(message) {
21 if (!SLACK_URL) return;
22 await fetch(SLACK_URL, {
23 method: 'POST',
24 headers: { 'Content-Type': 'application/json' },
25 body: JSON.stringify({ text: `Health Alert: ${message}` }),
26 });
27}
28
29checkHealth();

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 working example

notify.js
1/**
2 * Build failure notification script
3 * Sends alerts to Slack or Discord via webhooks
4 *
5 * Usage: node notify.js "Error description here"
6 *
7 * Required Secrets:
8 * SLACK_WEBHOOK_URL or DISCORD_WEBHOOK_URL
9 */
10
11const SLACK_URL = process.env.SLACK_WEBHOOK_URL;
12const DISCORD_URL = process.env.DISCORD_WEBHOOK_URL;
13
14async function sendAlert(message) {
15 const url = SLACK_URL || DISCORD_URL;
16 if (!url) {
17 console.error('No webhook URL found. Add SLACK_WEBHOOK_URL or DISCORD_WEBHOOK_URL to Secrets.');
18 process.exit(0);
19 }
20
21 const isDiscord = url.includes('discord.com');
22 const payload = isDiscord
23 ? { content: message }
24 : { text: message };
25
26 try {
27 const res = await fetch(url, {
28 method: 'POST',
29 headers: { 'Content-Type': 'application/json' },
30 body: JSON.stringify(payload),
31 });
32
33 if (res.ok) {
34 console.log('Alert sent successfully');
35 } else {
36 console.error(`Webhook returned ${res.status}`);
37 }
38 } catch (err) {
39 console.error('Failed to send alert:', err.message);
40 }
41}
42
43const errorMessage = process.argv[2] || 'Build failed';
44const appName = process.env.REPL_SLUG || 'Unknown App';
45const timestamp = new Date().toISOString();
46
47sendAlert(`[${timestamp}] Build failure in *${appName}*: ${errorMessage}`);

Common mistakes when getting build failure notifications in Replit

Why it's a problem: Hardcoding the webhook URL directly in the notification script

How to avoid: Store the URL in Tools > Secrets as SLACK_WEBHOOK_URL or DISCORD_WEBHOOK_URL. Access it via process.env in your code.

Why it's a problem: Forgetting to add 'exit 1' after sending the notification, causing the build to succeed despite the failure

How to avoid: Always include 'exit 1' after the notification call: 'tsc || (node notify.js "compile failed" && exit 1)'. This ensures the deployment is properly aborted.

Why it's a problem: Not adding the webhook secret to the Deployments pane, so notifications work in development but not during actual deployments

How to avoid: Open the Deployments pane, go to Settings, and add SLACK_WEBHOOK_URL as a deployment secret. Workspace secrets do not carry to deployments.

Why it's a problem: Using the Discord webhook payload format for Slack or vice versa

How to avoid: 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

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I'm deploying an app on Replit and want to receive Slack notifications whenever a deployment build fails. How do I create a notification script that triggers on build failures and sends the error message to a Slack webhook?

Replit Prompt

Create a build failure notification system. Add a notify.js script that sends alerts to Slack via a webhook URL stored in Secrets. Update the package.json build scripts to call notify.js when compilation or tests fail. Make sure the build still exits with a non-zero code after notifying.

Frequently asked questions

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.

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.

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.

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.

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

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.

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.

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.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.