Getting Axios NotFound error

I am sending photos across to an API. Because of the CORS error that I am facing, I made a proxy server that acts as the middle server. My front-end VueJS app will send data to the middle proxy, which then continues to the end server, which is the API.

Below is the server code:

// CAMERA API'/meitu', (req, res) => {
  const myFile =;

  //  mv() method places the file inside public directory`./public/tempData/${}`, function (err) {
      if (err) {
          return res.status(500).send({ msg: "Error has occured" });
  console.log("Uploading data to server...")

  let data = new FormData();
  data.append('photo', fs.createReadStream(`./public/tempData/${}`));
  // Token, URL, and Cookie are censored for privacy purposes.
  let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: '-------------------------------',
    headers: { 
      'userToken': '--------------------------------------------', 
      'Cookie': '.AspNetCore.Session=-----------------------------------',
    data : data

    .then(response => {
      console.log("Data sending complete.")
        return res.send(JSON.stringify(result));
      .catch((error) => {

and I get this ERROR:

Nov 7 01:23:04 PM  AxiosError: getaddrinfo ENOTFOUND
Nov 7 01:23:04 PM      at AxiosError.from (/opt/render/project/src/node_modules/axios/dist/node/axios.cjs:837:14)
Nov 7 01:23:04 PM      at RedirectableRequest.handleRequestError (/opt/render/project/src/node_modules/axios/dist/node/axios.cjs:3029:25)
Nov 7 01:23:04 PM      at RedirectableRequest.emit (node:events:513:28)
Nov 7 01:23:04 PM      at eventHandlers.<computed> (/opt/render/project/src/node_modules/follow-redirects/index.js:14:24)
Nov 7 01:23:04 PM      at ClientRequest.emit (node:events:513:28)
Nov 7 01:23:04 PM      at TLSSocket.socketErrorListener (node:_http_client:502:9)
Nov 7 01:23:04 PM      at TLSSocket.emit (node:events:513:28)
Nov 7 01:23:04 PM      at emitErrorNT (node:internal/streams/destroy:151:8)
Nov 7 01:23:04 PM      at emitErrorCloseNT (node:internal/streams/destroy:116:3)
Nov 7 01:23:04 PM      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
Nov 7 01:23:04 PM    hostname: '',
Nov 7 01:23:04 PM    syscall: 'getaddrinfo',
Nov 7 01:23:04 PM    code: 'ENOTFOUND',
Nov 7 01:23:04 PM    errno: -3008,

Nov 7 01:23:04 PM    cause: Error: getaddrinfo ENOTFOUND v<---------->.com   // Actual address redacted for privacy
Nov 7 01:23:04 PM        at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
Nov 7 01:23:04 PM      errno: -3008,
Nov 7 01:23:04 PM      code: 'ENOTFOUND',
Nov 7 01:23:04 PM      syscall: 'getaddrinfo',
Nov 7 01:23:04 PM      hostname: ''
Nov 7 01:23:04 PM    }
Nov 7 01:23:04 PM  }

Postman works completely fine, and I used the code from Postman, and I get the above error. How to fix this?

I deployed the server on Render.

can the server resolve the IP of the host you’re sending to it?
are you doing something silly like putting a protocol name on the front of the hostname?

I could just have a quick look sitting at the doctors waiting room.

Are you sure that is a synchronous function? Or do you miss an await here?

Is infinity a valid define/variable or do you need quotes here?

It’s just any other function that will just move the file.

It’s a valid variable, so no quotes needed.

What troubles me is the axios error with code -3008! Changing to Heroku is of no use.

No, it can’t.

And the API address is as follows: The API address used in the code is exactly what I was given by the third party.

I forgot to mention: sometimes it works fine, but most of the time, the program timeout on me.

Like, I happen to be lucky and got some data from the API like once or twice, and later, the middle server spits the timeout error on me again.

Right, but i’m fairly sure that getAddrInfo is expecting a protocol-less address, at least according to the googling i did.

So if it can’t resolve the IP of the server, how do you expect it to communicate with said server?
If the server address isnt resolvable through normal DNS, you should add it to your system’s hosts resolution file so it can find the server.

Well, asa matter of fact, I do not know whether it can resolve or not. Sometimes I could reach the server, but most of the time the request timed out more frequently. And even with the protocol, I was sometimes lucky.

And you are sure that there is no limitation on server site for number of request?

Well, now that you mentioned it… I only use my laptop and mobile phone to access the server.

Do I need to adjust something in Heroku?

As @m_hutley said, the ENOTFOUND error typically means that the DNS lookup failed when trying to resolve the hostname into an IP address, which could happen if the hostname is incorrect, the server is not reachable, or there’s an issue with the DNS configuration.

Given that your code works fine in Postman but not when deployed to Render, here are several steps you can take to troubleshoot and potentially resolve this issue:

  1. Double-check the URL: Make sure that the URL you are using in your server code is exactly the same as the one you are using in Postman. A common mistake is to have a typo or missing part in the URL.

  2. DNS Configuration: Check the DNS settings on Render to ensure that they are correct and that the hostname can be resolved from the Render environment. You may also want to try resolving the DNS manually from a terminal in the Render environment, if possible.

  3. HTTP vs. HTTPS: Make sure you’re using the correct protocol (HTTP vs. HTTPS). If the API requires HTTPS and you are using HTTP, or vice versa, the connection will fail.

  4. Environment Variables: If you are using environment variables to store the API URL or tokens, make sure they are set correctly in the Render environment.

  5. Proxy Settings: If Render requires you to use a proxy to make outbound HTTP requests, ensure your code or environment is correctly configured to use this proxy.

  6. Firewall/Network Issues: There could be firewall restrictions or network issues on Render’s side that are preventing the DNS lookup or the connection to the API server. Check if Render has any documentation on outbound requests or contact their support.

  7. Dependencies: Ensure that all your dependencies, particularly axios, are up to date and compatible with the environment where your server is deployed.

  8. Error Handling: Improve error handling in your .catch block to log more detailed information about the error. Sometimes the error object contains additional details that can help you troubleshoot.

.catch((error) => {
  if (error.response) {
    // Request made and server responded
  } else if (error.request) {
    // The request was made but no response was received
  } else {
    // Something happened in setting up the request that triggered an Error
    console.log('Error', error.message);
  1. Headers and Body: Ensure the headers and body of the request are formatted correctly, and that they match what the API expects, which you say works correctly when tested with Postman.

Good luck :thinking:

Actually yes, the URL that I used is EXACTLY the same as Postman, and the chance of successfully getting data from the API is just 30%, and it’s always HTTPS for me. I’ve switched to Heroku again btw, so there may be other stuff that I might have missed… and if there was firewall issues, then I wouldn’t have gotten anything at all, which wasn’t true. I manage to contact the API, but with such small chance.

It may be some network issues on Heroku’s side.

Do you have a paid account for this API or is it a costless? How many requests are you sending in a hour/minute/second? As I said, many costless services block if you use it too much.

1 Like

Heroku account alone is free, it costs $7 (basic plan) to host each app. I probably sent about two or three requests in a minute.

But my previous projects involving API work never had any issues. My earlier version of the project, which separate from the problematic one I have now, works perfectly fine, with no real errors, even if I sent about five-ten requests in a minute. It also ran on the $7 plan on Heorku. The service for the early version is currently suspended.

Both the current project and the early project run on servers hosted by Heroku for $7, and only the newest one had issues.

UPDATE: You are right, @Thallius. The API requests for the early project also timed out on me. Too many requests in a short period of time will clog the server. Thanks for the heads-up.

1 Like