Communication is no longer possible due to ECONNREFUSED error

My Discordbot just stopped working with the error “connect ECONNREFUSED”.
I have confirmed that it was working until yesterday.
I get the same ECONNREFUSED error when trying to connect to anything other than Discordbot in the same repository.
I also called “npm search” from the Shell tab and the same thing happened here.

Does anyone know why this happens and what I can do to prevent it?

$ npm search express
npm ERR! code ECONNREFUSED
npm ERR! syscall connect
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmjs.org/-/v1/search?text=express&size=20&from=0&quality=0.65&popularity=0.98&maintenance=0.5 failed, reason: connect ECONNREFUSED 104.16.16.35:443
npm ERR!     at ClientRequest.<anonymous> (/home/runner/Keiso2DiscordBot/.config/npm/node_global/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:513:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:494:9)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR!  FetchError: request to https://registry.npmjs.org/-/v1/search?text=express&size=20&from=0&quality=0.65&popularity=0.98&maintenance=0.5 failed, reason: connect ECONNREFUSED 104.16.16.35:443
npm ERR!     at ClientRequest.<anonymous> (/home/runner/Keiso2DiscordBot/.config/npm/node_global/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:513:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:494:9)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect',
npm ERR!   address: '104.16.16.35',
npm ERR!   port: 443,
npm ERR!   type: 'system'
npm ERR! }
npm ERR! 
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in: /home/runner/.npm/_logs/2023-05-26T02_09_08_610Z-debug-0.log

The error “ECONNREFUSED” is a standard error message indicating that your application attempted to open a network connection to a server, but the server rejected the connection.

Given the details you’ve provided, the error originates from your Discord bot attempting to connect to the npm registry, but it was unable to.

This can happen due to several reasons…

My 2 cents would be you debugging the error until you find the main cause

You could try to directly connect to the npm registry using the curl command: curl -v https://registry.npmjs.org/ . This can help verify whether your Replit instance can reach the npm registry directly or not. (I don’t know if you are allowed to do this action but try anyway).

You can also enable more detailed logging by enabling npm’s verbose logging, by running npm --loglevel verbose. Bring the details here so we can help you more.

It can just be a connectivity issue too and is already ok by now.

@QwertyQwerty88 It seems that several people are having the same problem, it would be the case to create a main topic of cases that have this error with Discord Bots? (ECONNREFUSED)

Another two cases here too: Discord Bot not working (worked before just stopped out of nowhere) - #10 by acerifleyt

2 Likes

2 posts were merged into an existing topic: ECONNREFUSED on all requests from discord bot repls

I have not been able to find an effective solution to this error, so I am assuming that some problem has been removed over time.
I have not made any modifications between the last time the error appeared and when it was resolved.