I've been facing ETIMEOUT error always when I try to make a call to microsoft graph api with axios. I am on the Ubuntu VMware right now and using node - 20.19.2.
I tried to find a solution here and there including chatgpt, but anything couldn't help me. When I tried to run same code base on the Windows host, it works fine.
test.js
import axios from "axios";
let data = JSON.stringify({
"subject": "New Event",
"body": {
"contentType": "HTML",
"content": "Does next month work for you?"
},
"start": {
"dateTime": "2025-06-10T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2025-06-10T14:00:00",
"timeZone": "Pacific Standard Time"
}
});
let config = {
method: 'post',
maxBodyLength: Infinity,
host: 'graph.microsoft.com',
url: 'https://graph.microsoft.com/v1.0/me/events',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer token'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Error log:
Network error: AggregateError [ETIMEDOUT]:
at internalConnectMultiple (node:net:1122:18)
at internalConnectMultiple (node:net:1190:5)
at Timeout.internalConnectMultipleTimeout (node:net:1716:5)
at listOnTimeout (node:internal/timers:583:11)
at process.processTimers (node:internal/timers:519:7) {
code: 'ETIMEDOUT',
[errors]: [
Error: connect ETIMEDOUT 20.190.144.169:443
at createConnectionError (node:net:1652:14)
at Timeout.internalConnectMultipleTimeout (node:net:1711:38)
at listOnTimeout (node:internal/timers:583:11)
at process.processTimers (node:internal/timers:519:7) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '20.190.144.169',
port: 443
},
...
I run node test.js from terminal.
Thanks for any help.
Finally, I fixed the problem, at least workaround.
As you know, Since Node20+, they use the ipv6 dns first. so I downgrade the node to 18 and it works now.