1

I am getting the following error when using the twilio node module

{ Error: read ECONNRESET
    at exports._errnoException (util.js:1026:11)
    at TLSWrap.onread (net.js:569:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
{ status: 'ECONNRESET',
  message: 'Unable to reach host: "api.twilio.com"' }

I am able to send SMS messages through Postman and their console interface but when trying it through NodeJS I get the error.

The code that I have is this:

var express = require('express');
var app = express();
var twilio = require('twilio');

var accountSid = 'ACXXXXXXXXXXXXXXX';
var apiKey = 'XXXXXXXXXXXXXXXXXXX';
var apiSecret = 'XXXXXXXXXXXXXX';

var twilioClient = new twilio.RestClient(accountSid, apiSecret);

//var account = twilioClient.accounts(accountSid);

//Send an text message
twilioClient.messages.create({
    body: 'Hello from Node',
    to: '+my_num',  // Text this number
    from: '+twilio_num' // From a valid Twilio number
}, function(err, message) {
    if (err) {
        console.log(err);
    }
    else {
        console.log(message);
    }
});

I found a similar problem here and followed the posted solution but that didn't work. I am guessing this is an entirely different error.

Community
  • 1
  • 1
somtingwong
  • 361
  • 1
  • 6
  • 19
  • Your error is `ECONNRESET` so there is some sort of connection error between your server and Twilio. Are you able to make `curl` requests from your server to the Twilio API correctly? What version of the Twilio module, Node are you using, and what OS? – philnash Oct 28 '16 at 12:48
  • Have you figured our what was the problem? – bora89 Nov 15 '16 at 06:30

0 Answers0