When I'm trying to run "xterm" in termux, it says failed to open display : :0. Why so? I'm running xserver xsdl. Then tried running xterm in it after export DISPLAY=:0 . If I do export DISPLAY=10.94.XXX.XXX:1 , xterm runs fine. I tried to debug it using strace. This is the line, which seems to cause the problem sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused).
Can anyone help me sort out this problem?
Note:I've been discussing this problem on Xserver/xsdl . I was told it might be an android permission issue. So I'm searching for help here.
It seems there is some kind of firewall,which is blocking the connection. I was unable to solve this problem. But I found a work around.
1. Entered a terminal with root privilage.
(E.g : used command su in a terminal emulator)
2. Created a 2nd loop back network by ifconfig
(E.g : ifconfig lo:0 127.0.0.2 netmask 255.0.0.0 up)
3. Fortunately "XSERVER XSDL" recognized this new network without any complain(Never thought it could detect such a weird network).
4. At last set my display to new server from my chroot environment as shown in XSERVER welcome screen.
export DISPLAY=127.0.0.2:1
startfluxbox ( or any xclient program, now everything runs fine)  

Note 1: Each time my phone is restarted, I've to create the loopback network again. There might be some .rc files for adding startup scripts on android too. But I never bothered changing them(because I don't restart my phone often).
Note 2: I would really appreciate a true solution though(better if it works without root) because my method can't be applied on a non-rooted phone. So people with this problem but without a rooted phone can't use xserver untill someone finds another solution.