What is the Listen Address of my process ?

Hi,

We cant set the listen address of my java process to the IP address or any of the DNS names listen in the hosts file of the server.

We can access the resources of the pid in the web browser through

http://<IP / DNS>:port/console

Based on the pid, how can we find what is the listen address of my process ? Is it the IP address or the DNS?

'lsof' will tell you. Usually listeners bind to a specific port, or use getsocketname to acquire their own port and send it to a correspondent, like in passive FTP.

As far as IP goes, you can listen on 0.0.0.0 = any, localhost 127.0.0.1, any IP of devices on your host. Otherwise, you get nothing.

I'm sorry for not being more specific in my query.

The concern is while configuring the server if I specify the DNS name then

http://<IP>:port/console

Does not yeild the webpage and visa-versa. So i have to know using the pid is the server is listening on the DNS name, if so what is it and if it is listening on the IP address and what it is.

The server will definitely not listen on the DNS name but on IP address (numbers). Anything having to do with server/domain names is the part of DNS services, even if you see names in some listings.
You may well have a problem with DNS, though.

1 Like

Are you talking about one server pretending to be many? It depends on the HTTP Header referring page or original host name to decide which server to pretend to be, no magic, and with IP it must default.

How can i store the Listen IP address to a bash variable given a particular pid ?

I understand that different pids running on the same host may have different listen IP addresses.

Please try to give me the most generic command / script which needs no or less modification running on different operating systems.

lsof is pretty system-independent once you have one for each system. If you have multiple IP server sockets can be listened on 0.0.0.0 (all), 127.0.0.1 (localhost only)or any of those addresses, which would have different host.domain names.

In practice, usually one server listening on 0.0.0.0 splits connections on multiple virtual server file trees based on the http header host.domain name. The host can have one IP with many DNS CNAME host.domain names that resolve to it. Browsers putting that IP in the URL or running on the server host using 127.0.0.1 will get the default virtual host.domain web service.