fix issue with js script running on AWS EC2 Instances

Job ID: 32756153

Budget: $30 – $250 USD

I have a js code that's running on AWS EC2 Instances , the script sends API call to a service and store the responses

it was running very well , but today it start shows error . the error occur when EC2 Instances sends the the API request to the service

this is the error :
0|app | FetchError: request to [Here show the url which try to send request to] failed, reason: connect EHOSTUNREACH [Here shows IP address]
0|app | at ClientRequest.<anonymous> (/home/ubuntu/app/node_modules/node-fetch/lib/index.js:1461:11)
0|app | at ClientRequest.emit (node:events:379:20)
0|app | at TLSSocket.socketErrorListener (node:_http_client:494:9)
0|app | at TLSSocket.emit (node:events:379:20)
0|app | at emitErrorNT (node:internal/streams/destroy:188:8)
0|app | at emitErrorCloseNT (node:internal/streams/destroy:153:3)
0|app | at processTicksAndRejections (node:internal/process/task_queues:81:21) {
0|app | type: 'system',
0|app | errno: 'EHOSTUNREACH',
0|app | code: 'EHOSTUNREACH'
0|app | }


I need this to be fixed ASAP.


Also currently the responses data is stored in EC2 Instances memory. That’s mean if the instance was rebooted or stoped the data will be gone. So I want to store the responses to AWS S3, once a day to keep it as backup.


And finally I want the app.js script to run automatically after stops or reboot

So I need 3 things:
- Fix the error (this is needed to be fixed ASAP)
- Store the response to AWS S3 as backup so if the API call fails it should get data from AWS S3
- Run app.js script automatically after stop or start ec2 Instances
Related categories: JavaScript Amazon Web Services Amazon S3