[SOLVED] Cannot connect to Deluge daemon locally

General support for problems installing or using Deluge
Post Reply
User avatar
kkmic
New User
New User
Posts: 7
Joined: Tue Oct 20, 2015 10:08 am

[SOLVED] Cannot connect to Deluge daemon locally

Post by kkmic »

Solution wrote: Click to show solution
Original message follows:

Hello,

I know this issue was discussed over and over again (and to the death afterwards), as it has popped up all over my searches, yet nothing I have tried has worked so far, so I have decided to spam this forum once again with the same issue, hoping that someone can point me in the right direction.

A little bit of background:

I have a Raspberry Pi 2 with the default Raspbian distro installed. I have installed Deluge on it following closely the Thin Client guide (Raspbian uses System V, so I have followed the init.d Ubuntu Init Script Service guide) and everything worked almost "out of the box" with no issues: the daemon, the console, the web UI, and even the SSH tunnelling.

Two weeks ago the Raspbian started to randomly crash, so I have decided to reinstall it. I believe that one of the updates might have messed it up... I don't really know what was the root cause, but seems to run just fine now. Among other things I have reinstalled Deluge following the same guides/steps as before, while reusing the configuration files kept from the previous installation.

The situation:

The daemon runs fine, but I cannot connect to it using the console or the web UI. SSH tunnelling also does not work. But I can connect to it using the GTK client installed on my Windows machine that is in the same local network.

What I have checked/tried:
  1. The firewall rules

    Code: Select all

    kkmic@raspberrypi ~ $ sudo iptables -L -n
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination
    
    No rule seems to be in place.
  2. The port used by the daemon

    Code: Select all

    kkmic@raspberrypi ~ $ sudo netstat -tuplne
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode       PID/Program name
    ...
    tcp        0      0 0.0.0.0:58846           0.0.0.0:*               LISTEN      1001       1883110     21923/python
    ...
    
    AFAIK, 0.0.0.0 means "every IP address" so this should be fine.
  3. The daemon logs:
    Empty. The logfile gets created though.
  4. The username deluged runs as:
    The daemon is configured to run as my user:

    Code: Select all

    kkmic@raspberrypi ~ $ cat /etc/default/deluge-daemon 
    # Configuration for /etc/init.d/deluge-daemon
    
    # The init.d script will only run if this variable non-empty.
    DELUGED_USER="kkmic"
    
    # Should we run at startup?
    RUN_AT_STARTUP="YES"
    
    It runs as my user. In the netstat output above, the daemon is shown running and belonging to the user with the ID 1001. That is my ID.

    Code: Select all

    kkmic@raspberrypi ~ $ id kkmic
    uid=1001(kkmic) gid=1004(kkmic) groups=1004(kkmic)
    
    The console runs as my user, obviously. I have even tried to specifically run it as my user and specify the config file:

    Code: Select all

    sudo -u kkmic deluge-console -c ~/.config/deluge
    
    Still failed to connect.
  5. The deluge console log:
    Weird part is that the console does not give a specific reason why the connection failed. It literally displays this after about 30 seconds:

    Code: Select all

    Failed to connect to 127.0.0.1:58846 with reason:
    
    If does not specify a failure reason.

    I have used the -L debug and -l /home/kkmic/deluge.log options to generate a log file for the console.

    The log contained this:

    Code: Select all

    [INFO    ] 15:32:47 ui:121 Deluge ui 1.3.12
    [DEBUG   ] 15:32:47 ui:122 options: {'loglevel': 'debug', 'logfile': '/home/kkmic/deluge.log', 'config': None, 'quiet': False}
    [DEBUG   ] 15:32:47 ui:123 args: []
    [INFO    ] 15:32:47 ui:124 Starting console ui..
    [DEBUG   ] 15:32:47 main:155 Using encoding: UTF-8
    [INFO    ] 15:32:47 client:217 Connecting to daemon at 127.0.0.1:58846..
    [DEBUG   ] 15:32:47 coreconfig:43 CoreConfig init..
    [DEBUG   ] 15:32:47 screen:82 Screen init!
    [WARNING ] 15:33:17 client:220 Connection to daemon at 127.0.0.1:58846 failed: User timeout caused connection failure.
    [DEBUG   ] 15:33:17 client:400 connect_fail: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.TimeoutError'>: User timeout caused connection failure.
    ]
    [DEBUG   ] 15:33:17 client:541 on_connect_fail: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.TimeoutError'>: User timeout caused connection failure.
    ]
    
    I have searched for more info about the errors, but I was not able to find any meaningful answers.
  6. The configuration files:
    I have moved the ~/.config/deluge folder and restarted the deluged. This recreated the configuration folder, so the daemon is reading the correct configuration files.

    I have searched in /usr/lib/deluge/ for configuration files but the folder does not exist.
  7. Mismatched component versions:

    Code: Select all

    kkmic@raspberrypi ~ $ deluged -v
    deluged: 1.3.12
    libtorrent: 0.15.10.0
    kkmic@raspberrypi ~ $ deluge-console -v
    deluge-console: 1.3.12
    libtorrent: 0.15.10.0
    
    Everything seems fine.
So here I am still clueless about what can cause this.

Again, remote connections work, local connections do not.

Help
Last edited by kkmic on Tue Oct 20, 2015 8:44 pm, edited 1 time in total.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Cannot connect to Deluge daemon locally

Post by Cas »

That error in logs possible suggests an issue with Twisted, what version of Twisted is installed? Could try reinstalling it.

Have you tried running deluged without service files and a fresh config and then test connecting with deluge-console on the RPi.
User avatar
kkmic
New User
New User
Posts: 7
Joined: Tue Oct 20, 2015 10:08 am

Re: Cannot connect to Deluge daemon locally

Post by kkmic »

Making progress, it seems, still not there yet.

First of all, somehow, python-twisted was not installed. And yes, everything was installed using apt-get.

I have installed python twisted now (it installed a few other dependencies).

Code: Select all

kkmic@raspberrypi ~ $ apt-cache policy python-twisted
python-twisted:
  Installed: 12.0.0-1
  Candidate: 12.0.0-1
...

kkmic@raspberrypi ~ $ python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import twisted
>>> print twisted.version
[twisted, version 12.0.0]
I have restarted the daemon. No luck though. Still the same error.

Following advice #2, I have removed the ~/.config/deluge folder and this happened:

Code: Select all

kkmic@raspberrypi ~ $ deluged -d
kkmic@raspberrypi ~ $ [ERROR   ] 16:59:36 rpcserver:376 Couldn't listen on localhost:58846: [Errno 99] Cannot assign requested address.
I tried to specify the local IP address:

Code: Select all

deluged -d -u 192.168.0.90
No errors this time. The config folder is created, the auth file is created, but the console still cannot connect to the daemon. :(

Not even when specifying the local IP, and a custom user and pass added to the auth file:

Code: Select all

[INFO    ] 17:30:24 ui:121 Deluge ui 1.3.12
[DEBUG   ] 17:30:24 ui:122 options: {'loglevel': 'debug', 'logfile': '/home/kkmic/deluge2.log', 'config': None, 'quiet': False}
[DEBUG   ] 17:30:24 ui:123 args: []
[INFO    ] 17:30:24 ui:124 Starting console ui..
[DEBUG   ] 17:30:24 main:155 Using encoding: UTF-8
[INFO    ] 17:30:24 client:217 Connecting to daemon at 127.0.0.1:58846..
[DEBUG   ] 17:30:24 coreconfig:43 CoreConfig init..
[DEBUG   ] 17:30:24 screen:82 Screen init!
[WARNING ] 17:30:54 client:220 Connection to daemon at 127.0.0.1:58846 failed: User timeout caused connection failure.
[DEBUG   ] 17:30:54 client:400 connect_fail: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.TimeoutError'>: User timeout caused connection failure.
]
[DEBUG   ] 17:30:54 client:541 on_connect_fail: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.TimeoutError'>: User timeout caused connection failure.
]
[INFO    ] 17:31:09 client:217 Connecting to daemon at 192.168.0.90:58846..
[WARNING ] 17:31:39 client:220 Connection to daemon at 192.168.0.90:58846 failed: User timeout caused connection failure.
[DEBUG   ] 17:31:39 client:400 connect_fail: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.TimeoutError'>: User timeout caused connection failure.
]
[DEBUG   ] 17:31:39 client:541 on_connect_fail: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.TimeoutError'>: User timeout caused connection failure.
]
Like before, no reason gets specified.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Cannot connect to Deluge daemon locally

Post by Cas »

This suggests your whole problem:

Code: Select all

kkmic@raspberrypi ~ $ [ERROR   ] 16:59:36 rpcserver:376 Couldn't listen on localhost:58846: [Errno 99] Cannot assign requested address.
So by running `deluged -d -u 192.168.0.90` the clients cannot connect because there is nothing on localhost. Either fix the above issue or specify to ip address of deluged when connecting with console or webui.
User avatar
kkmic
New User
New User
Posts: 7
Joined: Tue Oct 20, 2015 10:08 am

Re: Cannot connect to Deluge daemon locally

Post by kkmic »

Success!
Cas wrote:So by running `deluged -d -u 192.168.0.90` the clients cannot connect because there is nothing on localhost. Either fix the above issue or specify to ip address of deluged when connecting with console or webui.
In my particular case, the loopback interface was down. In the file /etc/network/interfaces,the line that booted up the loopback interface got mangled up, so there was no localhost to connect to - the auto lo line turned into something else.

Once I started up the loopback interface, everything worked like a charm ... except that the GTK client on my machine now cannot connect... but that's another problem for another day. For tomorrow :) <- scratch that, it was a minor issue solved by copying back the original configuration files - now everything REALLY works.

Code: Select all

kkmic@raspberrypi ~ $ sudo netstat -tuplne
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode       PID/Program name
...
tcp        0      0 127.0.0.1:58846         0.0.0.0:*               LISTEN      1001       10376       3127/python
...
Lesson learned today: when in doubt, try pinging the localhost: https://www.raspberrypi.org/forums/view ... 7&p=566415


Thank a bunch Cas!
Post Reply