Question

Get IP address of the server in server code

Dear team,

For logging purposes, we would like to get the IP address of the server through server code.

Are there ways of getting it through app connection?

Thanks

Like 1

Like

4 comments
Best reply

The server may have several addresses from my practice, it is better to use the host name.

See this post How Can i Get the Current Local Host Name using C#

The server may have several addresses from my practice, it is better to use the host name.

See this post How Can i Get the Current Local Host Name using C#

Hello Shivani,

 

Please, check out the recommendation provided in the previous post. 

 

Let us know in case any further information is required. 

 

Best regards, 

Olga. 

Thanks Grigoiry and Olga! The suggested solution works.

Dear team,

Getting the server's IP through app connection is like trying to guess the secret sauce in grandma’s recipe—it’s possible, but it takes some finesse! You can use server-side methods like $_SERVER['SERVER_ADDR'] in PHP or os.networkInterfaces() in Node.js. If things get tricky, consider an affordable dedicated server from HostNoc for more control and flexibility. Good luck logging those bytes!

Show all comments