EADDRNOTAVAIL Node JS

32 views Asked by At

Title: "Encountering EADDRNOTAVAIL Error After Processing Specific Number of Requests in Node.js"

Body: I have two servers set up. One is named processUpdate and the other actionUpdate.

On my actionUpdate server, I'm using Express to handle routes and save data to a database.

My processUpdate server prepares the data and sends requests to the actionUpdate server using axios to process my data.

The flow is like this: processUpdate -> 27345 -> actionUpdate.

I'm reading an 800,000-line file, and consistently, when I reach around 400,000 lines processed, I receive the following error:

Request failed: Error: connect EADDRNOTAVAIL xx.xx.xx:23745 - Local (xx.xx.xx:0)

I process the operations in chunks of 100:

const content800k = chunk(list, 100)

for :
await processChunk(chunkElement)

I can't seem to find an error on my actionUpdate server. Could the problem lie within my processUpdate server? What could be causing this error, and how might I resolve it?

I tried running my actionUpdate server with 16 processes, but I still received the same error at the same point.

EDIT

    const keepAliveAgent = new Agent({
  maxSockets: 100,
  maxFreeSockets: 10,
  timeout: 60000, // active socket keepalive for 60 seconds
  freeSocketTimeout: 30000, // free socket keepalive for 30 seconds
});

const axiosInstance = axios.create({httpAgent: keepAliveAgent});

this solution work for me :)

1

There are 1 answers

2
Cravecomm On

If you attempt to make a connection to a remote server in your physical computer (in your case, the remote server's ip address is xx.xx.xx.xx, and you're trying to connect to it in your physical computer), you will get EADDRNOTAVAIL error due to security reasons.

Therefore, you should write your server codes in RDP (remote desktop connection) computer, not in your physical computer. For this, open RDP app in Windows, make a remote desktop connection to your remote server (remote PC) by entering your server's ip address, your username and password, and after connecting, write your server codes in that remote computer. After you apply all these steps, your codes must work.