# How to: get server IP?

**URL:** https://community.wowza.com/t/how-to-get-server-ip/34457
**Category:** Wowza Streaming Engine
**Created:** [March 23, 2010, 10:32pm UTC](https://community.wowza.com/t/how-to-get-server-ip/34457 "2010-03-23T22:32:45Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Dan\_Daemon](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@Dan\_Daemon](https://community.wowza.com/u/Dan_Daemon)
#### Post date: [March 23, 2010, 10:32pm UTC](https://community.wowza.com/t/how-to-get-server-ip/34457/1 "2010-03-23T22:32:45Z")

</div>

Hello guys,

I need to get server IP to store in the database. Is it possible?

Server - the server where I launch my wowza application.

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [March 23, 2010, 11:47pm UTC](https://community.wowza.com/t/how-to-get-server-ip/34457/2 "2010-03-23T23:47:49Z")

</div>

Flash/Flex applications can get data from server-pages, which connect to the database. So it is indirect. It’s not difficult but we don’t have any guidance on that here. In Flash the simple method is Loadvars. Flex adds the HTTPService.

Wowza modules can connect to a database directly using JDBC, but I don’t think you want that in this context.

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [March 24, 2010, 9:24am UTC](https://community.wowza.com/t/how-to-get-server-ip/34457/3 "2010-03-24T09:24:23Z")

</div>

Take a look at this howto:

[http://www.rgagnon.com/javadetails/java-0390.html](http://www.rgagnon.com/javadetails/java-0390.html)

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [March 24, 2010, 1:55pm UTC](https://community.wowza.com/t/how-to-get-server-ip/34457/4 "2010-03-24T13:55:48Z")

</div>

Further info: It’s not possible, because it is too late in onAppStart to do what you want to do, and there is not another way.

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [March 24, 2010, 3:31pm UTC](https://community.wowza.com/t/how-to-get-server-ip/34457/5 "2010-03-24T15:31:52Z")

</div>

Okay, great. So all you need was to know what it is, not change it. That is good.

Richard

---

<div class="post-metadata">

### Author: ![Jake\_Hilton](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jake\_Hilton](https://community.wowza.com/u/Jake_Hilton)
#### Post date: [March 10, 2014, 9:48am UTC](https://community.wowza.com/t/how-to-get-server-ip/34457/6 "2014-03-10T09:48:58Z")

</div>

Just to add some more value to an old thread… one can use the following to get the public ip of a server if it’s NAT’d.

```auto
    private String getPublicServerIP()
    {
        String ip = null; //you get the IP as a String
        try
        {
            URL myip = new URL("http://checkip.amazonaws.com/");
            BufferedReader in = new BufferedReader(new InputStreamReader(myip.openStream()));
            ip = in.readLine();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
        return ip;
    }

```

Thanks,

Jake

---

<div class="post-metadata">

### Author: ![Dan\_Daemon](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@Dan\_Daemon](https://community.wowza.com/u/Dan_Daemon)
#### Post date: [March 24, 2010, 11:04am UTC](https://community.wowza.com/t/how-to-get-server-ip/34457/7 "2010-03-24T11:04:05Z")

</div>

Hello Richard,

Thank you very much for your answer. The problem is that I need to determinate server IP in the onAppStart function. Server IP which hosts application. Now I do it manually using Application.xml properties. But I need to manually set correct IP for each server instance that is not good and I’m looking for way to determinate the IP automatically in function onAppStart.

---

<div class="post-metadata">

### Author: ![Dan\_Daemon](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@Dan\_Daemon](https://community.wowza.com/u/Dan_Daemon)
#### Post date: [March 24, 2010, 5:23pm UTC](https://community.wowza.com/t/how-to-get-server-ip/34457/8 "2010-03-24T17:23:45Z")

</div>

Hello Richard,

Thank you again for your help. I did so:

```auto
	private String getServerIP() {
		try {
			InetAddress address = InetAddress.getLocalHost();
			return address.getHostAddress();
		} catch( Exception error ) {
			getLogger().error( "getServerIP() error" );
		}
		return "127.0.0.1";
	}

```

And I call this function like:

```auto
public void onAppStart( IApplicationInstance instance ) {
	String ip = getServerIP();
	long roomIP = Strings.IpToLong( ip );

```

It works properly, i.e. I get server IP.

Thanks,

D
