rasa: Max retries exceeded and connection refused errors when running Rasa Stack

Rasa version: Core = 0.14.4, Core-sdk = 0.14.0, NLU = 0.15.0

Python version: 3.6.7

Operating system (windows, osx, …): Ubuntu 18.04.2 LTS

Issue: I have been using the Rasa Stack starter-pack for which the files within it within it remain unchanged apart from the Makefile which I changed the instances of python to python3. I attempted to get Rasa Stack working as a server using the RestInput channel as described in https://rasa.com/docs/core/connectors/#rest-channels. I used the example to connect the rest input channel using the run script:

python3 -m rasa_core.run -d models/current/dialogue -u models/current/nlu --port 5002 --credential credentials.yml

This initally worked but my attempt to post a message using the following code:

import requests

URL = 'http://localhost:5010/webhooks/rest/webhook/'
PARAMS = {'sender': "ola", 'message': "how are you"}

r = requests.get(URL)

data = r.json()
print(data)

resulted in a error to do with Max retries exceeded with url and connection refusal. The issue is since then, I have not been able to get the server up and running, with or without the commandline interface. When I try to connect the rest input channel as above, I get the following error:

r/lib/python3.6/runpy.py:125: RuntimeWarning: 'rasa_core.run' found in sys.modules after import of package 'rasa_core', but prior to execution of 'rasa_core.run'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
2019-05-21 08:38:27 INFO     root  - Rasa process starting
2019-05-21 08:38:45 INFO     rasa_nlu.components  - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-en'.
Traceback (most recent call last):
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 355, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connection.py", line 183, in connect
    conn = self._new_conn()
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f58af883ba8>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/thales/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/thales/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=5002): Max retries exceeded with url: /webhooks/rest/webhook/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f58af883ba8>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.6/dist-packages/rasa_core/run.py", line 204, in <module>
    endpoints=_endpoints)
  File "/usr/local/lib/python3.6/dist-packages/rasa_core/run.py", line 157, in load_agent
    from rasa_core import agent
  File "/usr/local/lib/python3.6/dist-packages/rasa_core/agent.py", line 14, in <module>
    from rasa_core.channels import UserMessage, OutputChannel, InputChannel
  File "/usr/local/lib/python3.6/dist-packages/rasa_core/channels/__init__.py", line 23, in <module>
    from rasa_core.channels.telegram import TelegramInput  # nopep8
  File "/usr/local/lib/python3.6/dist-packages/rasa_core/channels/telegram.py", line 4, in <module>
    from telegram import (
  File "/home/thales/.local/lib/python3.6/site-packages/telegram/__init__.py", line 46, in <module>
    from .files.file import File
  File "/home/thales/.local/lib/python3.6/site-packages/telegram/files/file.py", line 23, in <module>
    from future.backports.urllib import parse as urllib_parse
  File "/home/thales/.local/lib/python3.6/site-packages/future/backports/__init__.py", line 14, in <module>
    import_top_level_modules()
  File "/home/thales/.local/lib/python3.6/site-packages/future/standard_library/__init__.py", line 810, in import_top_level_modules
    with exclude_local_folder_imports(*TOP_LEVEL_MODULES):
  File "/home/thales/.local/lib/python3.6/site-packages/future/standard_library/__init__.py", line 781, in __enter__
    module = __import__(m, level=0)
  File "/home/thales/ola/starter-pack-rasa-stack/test.py", line 6, in <module>
    r = requests.post(URL, data = PARAMS)
  File "/home/thales/.local/lib/python3.6/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/thales/.local/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/thales/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/thales/.local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/thales/.local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5002): Max retries exceeded with url: /webhooks/rest/webhook/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f58af883ba8>: Failed to establish a new connection: [Errno 111] Connection refused',))

The part of the error mentioning the port seems to depend on the port that was in my post message python script. The port in the command line arguments seems to be ignored. My attempt to debug the run.py file finds it breaks down at line 157 “from rasa_core import agent” which makes little sense as that import works fine on it’s own in a python terminal.

The “make cmdline” command bring up the same error as does the “make train-core” command.

I should note I can still create the action server and local servers for other things as well.

Content of configuration file (config.yml):

anguage: "en"

pipeline: spacy_sklearn

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

The error comes from the use of localhost

Docker introduces a virtual network, so each docker-isntance sees itself as 127 not the host machine

(thx @Jmons)


To launch your code locally, use your fixed IPv4 address.

For Windows users: open a command prompt (cmd) and run the ipconfig command, retrieve the IP@ which is atIPv4 address. . . . . . . . . . . . . .:it is generally of type 192.168.x.x