Obtain the IP Address of the server who runs the build command

Connected to this issue https://answers.netlify.com/t/gatsby-5-13-7-timeouts-on-netlify-not-local-only-since-a-while/124037 we need to obtain the IP Address of the server that runs the build command.
We need this IP Address to debug a timeout issue.

Is it logged somewhere in the Netlify UI (we cannot find it) or how do we add some logging to our deployment code that display the IP Adress (we use Gatsby) ?

We use this now

const https = require('https');

// Get the public IP address
https.get('https://api.ipify.org?format=json', (res) => {
  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    const ip = JSON.parse(data).ip;
    console.log('Your IP Address:', ip);
  });
}).on('error', (err) => {
  console.error('Error fetching IP:', err);
});

Any other way?

You could also make a DNS lookup to get that information but I don’t believe that would be any simpler or more reliable that the solution you are using now. I recommend using your method above.

There is also an Enterprise plan feature that provides static IP addresses for the build system but that is a paid feature on Enterprise plans only:

1 Like