Issue
If you see the error "TwilsockUpstreamError: Forbidden" when sending messages in Twilio Conversations Classic, this guide will help you understand and resolve the issue even if you’re not a developer.
You can log in, edit, or delete messages, but sending a new message gives you a "Forbidden" error. This usually happens in just one Twilio account or subaccount, while others work fine.
Product
Twilio Conversations
Environment
legacy Twilio Console
Cause
This error often means there’s a permissions or settings issue in the affected account. Sometimes, old settings from Twilio’s previous chat product (Programmable Chat) can interfere with Conversations Classic, especially if webhooks (automated notifications) are still set up.
Resolution
Step 1: Check for Old Chat Settings
- Log in to your Twilio Console.
- Go to the Programmable Chat section (even if you’re using Conversations now).
- Look for any services that match the one giving you trouble.
- Check if there are any webhook URLs (web addresses) listed.
- If you see any, clear them out and save your changes.
Step 2: Double-Check Conversations Settings
- In the Console, go to Conversations > Manage > Services.
- Select the service that’s having issues.
- Go to the Webhooks tab.
- Make sure all webhook events are turned off and no URLs are listed.
Step 3: Try Sending a Message Again
- Go back to your chat app and try sending a message.
- If it works, you’re all set!
Optional: Code Sample to Clear Webhooks
If you’re comfortable with code, you can use the following Python script to automatically clear old webhook URLs from a Programmable Chat service:
from twilio.rest import Client
# Replace with your Account SID and Auth Token from https://twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)
# Replace with your Chat Service SID (starts with IS...)
service_sid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
# This will clear both pre and post webhook URLs
service = client.chat.v2.services(service_sid).update(
pre_webhook_url='',
post_webhook_url=''
)
print(f"Cleared webhooks for service: {service.sid}")
- Make sure to replace the placeholders with your actual Account SID, Auth Token, and Service SID.
- This script will remove any webhook URLs from the specified Programmable Chat service.
Additional Information
Old webhook settings from Programmable Chat can block new messages in Conversations, even if everything else looks right. Removing these settings lets your messages go through.
If you’ve followed these steps and still see the error, you may need to check with your technical team or Twilio support for further investigation.