Error: connect ECONNREFUSED at exports._errnoException at TCPConnectWrap.afterConnect
Asked Answered
M

1

7

I am trying to download a file using a url link but I am getting following error

throw er; // Unhandled 'error' event

Error: connect ECONNREFUSED at exports._errnoException (util.js:746:11)

at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)

I have used wget url but I am getting below

failed: Connection refused

it was said that for https we need a server certificate and show it when we authenticate it but how to show certificate and get the file

i have used wireshark and saw that there is some problem with ssl handshake so i have downloaded the certificate of the server so what should i do now

My Nodejs code

var https = require('https');
var fs = require('fs');

var file = fs.createWriteStream("file.xlsx");
var request = https.get("https://example.com/secure/attachment/206906/a-373_update.xlsx", function(response) {
  response.pipe(file);
});
Midyear answered 27/7, 2015 at 4:32 Comment(13)
You use the http module for making HTTPS requests (you need to use the https module instead), which will throw an error (although a different one from what you're showing).Richthofen
@Richthofen it is showing same error even i have used the https module i have edited my post please seeMidyear
I assume that the URL is actually valid? Did you try retrieving it using something like cURL?Richthofen
i am able to download the file manually by pasting it in browser the url above is an example not an exatMidyear
And you're not using a proxy or something?Richthofen
no i am not using proxy there is some error with ssl handshake as seen in wiresharkMidyear
If your server requires a client certificate, check this answer.Richthofen
how to get client key and client.crtMidyear
That's something that the server owner should provide (if that's the reason for your problems).Richthofen
cant we create client key and .crt using site/server certificateMidyear
I don't think so, but it using client side certificates doesn't make sense in your use case (for instance, the server owner never mentions them), it may not be the cause of your problems.Richthofen
when i am using wget url i am getting failed: Connection refusedMidyear
what should i do nowMidyear
M
0

I had a similar issue - How to track down error in node network code? - while I doubt the details of your issue are the same as mine, it's likely that using the NODE_DEBUG environmental variable would help in your case also.

Mieshamiett answered 18/1, 2019 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.