1

Topic: import_users.py Error

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.7.4
- Deployed with iRedMail Easy or the downloadable installer?downloadable
- Linux/BSD distribution name and version: Almalinux9
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx):Nginx
- Manage mail accounts with iRedAdmin-Pro?yes.
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
I'm test to run import_users.py Error .
anything mistake?


[root@mx ~]# cat /tmp/acctest.txt
j.chakkrit@interlinktelecom.co.th,CKmi45dfsrio4k#df2013,,Chakkrit Jaiman,,20560006
[root@mx ~]# python3 /opt/www/iredadmin/tools/import_users.py /tmp/acctest.txt
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, 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 "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 700, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 395, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib64/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.9/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.9/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.9/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.9/http/client.py", line 980, in send
    self.connect()
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 200, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 181, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f4db4a1a880>: 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.9/site-packages/requests/adapters.py", line 612, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 756, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3.9/site-packages/urllib3/util/retry.py", line 576, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=8080): Max retries exceeded with url: /api/login (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4db4a1a880>: 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 "/opt/www/iredadmin/tools/import_users.py", line 136, in <module>
    r = requests.post(api_endpoint + '/login',
  File "/usr/lib/python3.9/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3.9/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 544, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 657, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.9/site-packages/requests/adapters.py", line 689, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8080): Max retries exceeded with url: /api/login (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4db4a1a880>: Failed to establish a new connection: [Errno 111] Connection refused'))
[root@mx ~]#

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: import_users.py Error

It tried to connect to 127.0.0.1:8080.
Do you use the correct iRedAdmin-Pro API endpoint in this file?

3

Re: import_users.py Error

ZhangHuangbin wrote:

It tried to connect to 127.0.0.1:8080.
Do you use the correct iRedAdmin-Pro API endpoint in this file?

how to use it? or must be change API endpoint ip from 127.0.0.1 to  iredmail server ip. but I run in local server . I'm confuse .

4

Re: import_users.py Error

It's clearly documented in the import_users.py, please read the comment lines in it:

# Usage:
#
#   - Make sure your iRedAdmin-Pro has RESTful API interface enabled by
#     following our tutorial:
#     https://docs.iredmail.org/iredadmin-pro.restful.api.html#enable-restful-api
#
#   - Generate file /opt/users.list which contains the mail accounts you want
#     to import, one account per line, with account info stored in few fields:
#
#     1: [REQUIRED] user's full email address.
#     2: [REQUIRED] plain text or password hash which starts with the password
#                   scheme name. For example, "{SSHA}xxx", "{SSHA512}xxx".
#     3: [optional] mailbox quota in MB. Must be an integer number.
#     4: [optional] full display name.
#     5: [optional] list of mailing list addresses. If not empty, user will be
#                   assigned to given mailing lists as a member.
#
#                   Notes:
#
#                   - Multiple addresses must be separated by ":".
#                   - If mailing list doesn't exist, it will not be created automatically.
#     6: [optional] employeeid: employee id.
#
#     NOTE: the separator "," for ending EMPTY optional fields is not required.
#
#     Samples:
#
#       user@domain.com, plain_password
#       user@domain.com, plain_password, 1024, Zhang Huangbin, list1@domain.com:list2@domain.com
#       user@domain.com, plain_password, , , list1@domain.com:list2@domain.com
#       user@domain.com, plain_password, 1024, Zhang Huangbin
#
#   - Update 3 parameters in this file:
#
#       api_endpoint = ''
#       verify_cert = True
#       admin = 'postmaster@a.io'
#       pw = 'password'
#
#     - "api_endpoint" is the endpoint of iRedAdmin-Pro RESTful API.
#     - With "verify_cert = True", a valid ssl cert is required on API
#       server (https://). If you don't have a valid ssl cert yet, please set
#       it to False.
#     - "admin" is the email address of domain admin which has privilege to
#             manage the email domain which you're going to import users to.
#     - "pw" is plain password of domain admin.
#
#   - Run commands below to create users listed in the "/opt/users.list" file:
#
#       python import_users.py /opt/users.list