my page is not communicating with twilio
theshowscout-ops
PROOP

18 days ago

I am getting a "Failed to fetch" error when I try to log into my site using two step authentication set up with Twilio.

$20 Bounty

3 Replies

Status changed to Open Railway 18 days ago


dev-charles254
PRO

18 days ago

A “Failed to fetch” error with Twilio 2FA on Railway is usually caused by one of these:

Your backend is not listening on process.env.PORT

The app is bound to localhost instead of 0.0.0.0

The Twilio callback/webhook URL is wrong or not public

CORS is blocking the frontend request

Your API route is crashing and returning 500

First make sure your server is started like this:

const PORT = process.env.PORT || 3000;

app.listen(PORT, '0.0.0.0', () => {

console.log(Running on ${PORT});

});

Then test your Railway API endpoint directly in the browser/Postman before testing Twilio.

Also check:

Railway deployment logs

Browser Network tab

Twilio Debugger logs

If the request never reaches your backend, it’s usually a Railway networking/CORS issue. If it reaches but fails, it’s probably the Twilio auth route throwing an error.


theshowscout-ops
PROOP

18 days ago

Thank you! Are you a developer? Any chance you want to help me repair this?


theshowscout-ops

Thank you! Are you a developer? Any chance you want to help me repair this?

dev-charles254
PRO

18 days ago

Yes, I’m a developer. To help you narrow it down quickly.

A few questions that would help identify the issue:

  1. What framework/backend are you using? (Next.js, Express, Flask, etc.)

  2. Is the “Failed to fetch” happening:

    before the OTP is sent,

    after entering the OTP,

    or during login verification?

  3. In your browser DevTools → Network tab, what status code does the failing request return?

    (404, 500, CORS error, timeout, etc.)

  4. Are there any errors in:

    Railway deployment logs
    
    Browser console
    
    Twilio Debugger logs
  5. What URL are you using for the Twilio callback/webhook?

    (You can redact secrets.)

  6. Does your backend listen using: process.env.PORT and 0.0.0.0 ?

  7. Can you successfully open your Railway API endpoint directly in the browser/Postman?

My first guess is either:

  CORS blocking the frontend request,

  Railway networking/binding issue,

  or the Twilio verification route crashing server-side.

Welcome!

Sign in to your Railway account to join the conversation.

Loading...