Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-fetch connect ETIMEDOUT error

I am trying to get 200 status code in response, but as a result it's ETIMEDOUT. I can't understand, how is it possible that I can grab successful response via postman, but same via node-fetch responding with ETIMEDOUT always. Here is an example of code:

const Resource = {
  get: cb => {
    fetch('https://example.com', {
      method: 'POST',
      headers: {'Content-Type': 'application/x-www-form-urlencoded'},
      body: {...some body...},
    }).then(res => {
      if (res.status !== 200) cb(`Status: ${res.status}, ${res.statusText}`)
      return res.text()
    }).then(data => {
        cb(null, data)
      }).catch((err) => {
       console.log('ERROR: ', err)
      })
  }
}

and here is response:

ERROR: { FetchError: request to https://example.com failed, reason: connect ETIMEDOUT at ClientRequest.<anonymous> (C:\Users\projects\DSSRQ\node_modules\node-fetch\lib\index.js:1393:11) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketErrorListener (_http_client.js:387:9) at emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) message: 'request to https://example.com failed, reason: connect ETIMEDOUT', type: 'system', errno: 'ETIMEDOUT', code: 'ETIMEDOUT' }

like image 378
blindeveloper Avatar asked Jun 30 '26 11:06

blindeveloper


1 Answers

It looks like it was because of the proxy limitation.

like image 117
blindeveloper Avatar answered Jul 02 '26 23:07

blindeveloper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!