Daemon Fails - error: [Errno 111] Connection Refused

Noticed Transmission wasn’t downloading anything for 48 hrs, so checked Flexget. Note that I will occasionally get ‘ACTIVE/RUNNING’, but if I check 2 seconds later, it’s FAILED again:

flexget.service - Flexget Daemon
   Loaded: loaded (/usr/lib/systemd/system/flexget.service; enabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Sun 2018-12-02 23:05:16 GMT; 7s ago
  Process: 735 ExecStart=/usr/bin/flexget -c /var/lib/flexget/config.yml daemon start (code=exited, status=1/FAILURE)
 Main PID: 735 (code=exited, status=1/FAILURE)

if I try:

/usr/bin/python2 /usr/bin/flexget -c /var/lib/flexget/config.yml daemon status

There is a FlexGet process already running for this config, sending execution there.
Could not start manager: [Errno 111] Connection refused

If you’d like a little more, I’ve also tried:

/usr/bin/flexget -c /var/lib/flexget/config.yml daemon status --debug
There is a FlexGet process already running for this config, sending execution there.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flexget/__init__.py", line 42, in main
    manager.start()
  File "/usr/lib/python2.7/site-packages/flexget/manager.py", line 339, in start
    client = IPCClient(ipc_info['port'], ipc_info['password'])
  File "/usr/lib/python2.7/site-packages/flexget/ipc.py", line 158, in __init__
    channel = rpyc.Channel(rpyc.SocketStream.connect('127.0.0.1', port))
  File "/usr/lib/python2.7/site-packages/rpyc/core/stream.py", line 132, in connect
    return cls(cls._connect(host, port, **kwargs))
  File "/usr/lib/python2.7/site-packages/rpyc/core/stream.py", line 102, in _connect
    s.connect(sockaddr)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused

I’ve googled for this error, but can find nothing that seems to relate to this. Can anyone shed any light on this?

This error means that the client cannot connect to the port on the computer running server script. This can be caused by few things, like lack of routing to the destination or you have a firewall somewhere between your client and the server - it could be on server itself or on the client etc. Note that a server must perform the sequence socket(), bind(), listen(), accept() (possibly repeating the accept() to service more than one client), while a client only needs the sequence socket(), connect(). Also note that the server does not sendall()/recv() on the socket it is listening on but on the new socket returned by accept(). Try the following:

  • Check if you really have that port listening on the server (this should tell you if your code does what you think it should): based on you OS, but on linux you could do something like netstat -ntulp
  • Check from the server, if you’re accepting the connections to the server: again based on your OS, but telnet LISTENING_IP LISTENING_PORT should do the job
  • Check if you can access the port of the server from the client , but not using the code: just us the telnet (or appropriate command for your OS) from the client