# Cannot get Unifi Controller to load login page



## fred974 (Aug 12, 2016)

Hi,

I followed the instruction here 
I tried to installed the Ubiquiti Unifi controller on a ezjail jand on my installation each time I go to the login page I get prompt to start the setup wizard over and over asking to set country and username and password. Once I set it all and go back to the page, I get the following error message when I login:
{{toast.message}}
I use gui 5.0.7.3093

Thank you in advance for your assistance


----------



## tobik@ (Aug 18, 2016)

Is this still an issue?

I have no problem running net-mgmt/unifi5 outside of a jail. Do you see anything more in /usr/local/share/java/unifi/logs/server.log?


----------



## fred974 (Aug 18, 2016)

Hi tobik
Thank you for your reply..
I have 2 messages
/usr/local/share/java/unifi/logs/server.log

```
<launcher> WARN system - cannot load native lib - ubnt_webrtc_jni
```
Message in chrome browser

```
{{toast.message}}
```
I ran the following 2 commands but I still get the error message
`rm /usr/local/share/java/unifi/lib/native/Linux/amd64/libubnt_webrtc_jni.so`
`rm /usr/local/share/java/unifi/lib/native/Linux/armhf/libubnt_webrtc_jni.so`

Running `find / -name 'libubnt_webrtc_jni.so'` doesn't return anything.

Do you think it is a jail specific problem?
I did and installation on FreeNAS jail with not problem at all...
But On my FreeBSD jail its not working


----------



## tobik@ (Aug 20, 2016)

fred974 said:


> Message in chrome browser


That looks like some kind of templating not being filled in correctly. Is `mongod` running? What do you see in `sockstat -P tcp` after starting the controller? Is /usr/local/share/java/unifi writable?


----------



## fred974 (Aug 23, 2016)

Hi tobik 

Sorry for the late reply..
`sockstat -P tcp`

```
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
root     mongod     16919 6  tcp4   10.8.20.27:27117      *:*
root     mongod     16919 14 tcp4   10.8.20.27:27117      10.8.20.27:39411
root     mongod     16919 15 tcp4   10.8.20.27:27117      10.8.20.27:39419
root     mongod     16919 16 tcp4   10.8.20.27:27117      10.8.20.27:39420
root     java       16883 61 tcp4   10.8.20.27:39411      10.8.20.27:27117
root     java       16883 68 tcp4   10.8.20.27:8080       *:*
root     java       16883 69 tcp4   10.8.20.27:8443       *:*
root     java       16883 70 tcp4   10.8.20.27:8843       *:*
root     java       16883 71 tcp4   10.8.20.27:8880       *:*
root     java       16883 77 tcp4   10.8.20.27:39419      10.8.20.27:27117
root     java       16883 79 tcp4   10.8.20.27:39420      10.8.20.27:27117
```
`ll /usr/local/share/java/unifi`

```
drwxr-xr-x  2 root   wheel     3 Aug 15 21:01 bin/
drwxr-xr-x  2 root   wheel     2 Aug 15 21:01 conf/
drwxr-xr-x  6 unifi  wheel     8 Aug 15 21:05 data/
drwxr-xr-x  3 root   wheel     3 Aug 15 21:01 dl/
drwxr-xr-x  3 root   wheel    47 Aug 15 21:01 lib/
drwxr-xr-x  2 unifi  wheel     4 Aug 15 21:56 logs/
-r--r--r--  1 root   wheel  1281 Jun  3 05:08 readme.txt
drwxr-xr-x  2 unifi  wheel     3 Aug 15 22:52 run/
drwxr-xr-x  3 root   wheel     3 Aug 15 21:01 webapps/
drwxr-xr-x  3 unifi  wheel     3 Aug 15 21:05 work/
```
All look ok to me.. can you spot any issue from that?
Could it be a problem with my pf rules?


----------



## tobik@ (Aug 23, 2016)

Here's how `sockstat -P tcp | grep unifi` looks on my system:

```
unifi    mongod     80401 6  tcp4   127.0.0.1:27117       *:*
unifi    mongod     80401 10 tcp4   127.0.0.1:27117       127.0.0.1:54827
unifi    mongod     80401 15 tcp4   127.0.0.1:27117       127.0.0.1:54830
unifi    mongod     80401 16 tcp4   127.0.0.1:27117       127.0.0.1:54831
unifi    mongod     80401 17 tcp4   127.0.0.1:27117       127.0.0.1:14965
unifi    java       80358 57 tcp4   127.0.0.1:54827       127.0.0.1:27117
unifi    java       80358 73 tcp4 6 *:8080                *:*
unifi    java       80358 74 tcp4 6 *:8443                *:*
unifi    java       80358 75 tcp4 6 *:8843                *:*
unifi    java       80358 76 tcp4 6 *:8880                *:*
unifi    java       80358 81 tcp4   127.0.0.1:54830       127.0.0.1:27117
unifi    java       80358 82 tcp4   127.0.0.1:54831       127.0.0.1:27117
unifi    java       80358 83 tcp4   127.0.0.1:14965       127.0.0.1:27117
```
What I notice is that `mongod` binds to 127.0.0.1 on my system and in your jail it binds to the jail's IP. The Unifi controller does a new MongoClient("127.0.0.1", ...) when starting up, which can't work when `mongod` is not bound to 127.0.0.1. This seems to be hardcoded in the code. Do you still have access to your FreeNAS jail? Can you post a sockstat output from there too? I'm wondering why it works there.

Does the controller even attempt to connect with your mongod' instance? Do you see anything interesting in /usr/local/share/java/unifi/logs/mongod.log?


----------



## fred974 (Aug 23, 2016)

Here is what I have on my FreeNAS box
`sockstat -P tcp | grep unifi` 

```
unifi    mongod     59747 6  tcp4   127.0.0.1:27117       *:*                  
unifi    mongod     59747 14 tcp4   127.0.0.1:27117       127.0.0.1:25596      
unifi    mongod     59747 15 tcp4   127.0.0.1:27117       127.0.0.1:25597      
unifi    mongod     59747 16 tcp4   127.0.0.1:27117       127.0.0.1:25598      
unifi    mongod     59747 17 tcp4   127.0.0.1:27117       127.0.0.1:20850      
unifi    mongod     59747 18 tcp4   127.0.0.1:27117       127.0.0.1:17545      
unifi    java       59432 57 tcp4 6 *:8443                *:*                  
unifi    java       59432 59 tcp4 6 *:8843                *:*                  
unifi    java       59432 60 tcp4   127.0.0.1:25596       127.0.0.1:27117      
unifi    java       59432 70 tcp4 6 *:8080                *:*                  
unifi    java       59432 71 tcp4 6 *:8880                *:*                  
unifi    java       59432 75 tcp4   127.0.0.1:25597       127.0.0.1:27117      
unifi    java       59432 76 tcp4   127.0.0.1:25598       127.0.0.1:27117      
unifi    java       59432 77 tcp4   127.0.0.1:20850       127.0.0.1:27117      
unifi    java       59432 85 tcp4   127.0.0.1:17545       127.0.0.1:27117
```
This look very much like yours.
I stopped unifi service and cleared all the log.. Here is the /usr/local/share/java/unifi/logs/mongod.log

```
2016-08-23T15:00:23.268+0000 [initandlisten] MongoDB starting : pid=84281 port=27117 dbpath=/usr/local/share/java/unifi/data/db 64-bit host=UniFi.mydomain.co.uk
2016-08-23T15:00:23.268+0000 [initandlisten] db version v2.6.12
2016-08-23T15:00:23.268+0000 [initandlisten] git version: nogitversion
2016-08-23T15:00:23.268+0000 [initandlisten] OpenSSL version: OpenSSL 1.0.1p-freebsd 9 Jul 2015
2016-08-23T15:00:23.268+0000 [initandlisten] build info: FreeBSD 101amd64-quarterly-job-15 10.1-RELEASE-p37 FreeBSD 10.1-RELEASE-p37 amd64 BOOST_LIB_VERSION=1_49
2016-08-23T15:00:23.268+0000 [initandlisten] allocator: system
2016-08-23T15:00:23.268+0000 [initandlisten] options: { net: { bindIp: "127.0.0.1", http: { enabled: false }, port: 27117 }, processManagement: { pidFilePath: "/var/run/mongod.pid" }, storage: { dbPath: "/usr/local/share/java/unifi/data/db" }, systemLog: { destination: "file", logAppend: true, path: "logs/mongod.log" } }
2016-08-23T15:00:23.269+0000 [initandlisten] journal dir=/usr/local/share/java/unifi/data/db/journal
2016-08-23T15:00:23.269+0000 [initandlisten] recover : no journal files present, no recovery needed
2016-08-23T15:00:23.295+0000 [initandlisten] waiting for connections on port 27117
2016-08-23T15:00:23.499+0000 [initandlisten] connection accepted from 10.8.20.27:11325 #1 (1 connection now open)
```
 Any idea how I get mongod to binds to 127.0.0.1


----------



## SirDice (Aug 23, 2016)

tobik said:


> Do you still have access to your FreeNAS jail? Can you post a sockstat output from there too? I'm wondering why it works there.


I'm guessing it's because FreeNAS uses VIMAGE/VNET jails. Those actually have a localhost interface. Regular jails however don't. 



fred974 said:


> Any idea how I get mongod to binds to 127.0.0.1


Jails don't have a lo0 interface and therefor no access to 127.0.0.1. You will need to bind it to the jail's IP address.


----------

