Timeout creating a new site - FreeBSD 13

I have successfully installed frappe on a Debian VM and after several runs, I believe I have gotten the hang of how things are configured.
I am now trying to install erpnext on FreeBSD 13 and I have installed everything. I am now at the point of creating a new site, and I get a timeout. The timeout talks about redis-server and not MySQL I migrated from MySQL to MariaDB just for this very purpose of getting erpnext running.
I am trying to figure out what is going on during the process of creating a new site. On the Debian VM, when I execute the command:

bench new-site site.name

I immediately get prompted for the MySQL root password. This is not happening on FreeBSD. The command stays there until it times out, and then gives the error:

[frappe@gw ~/frappe-bench]$ bench new-site --verbose my.site.name
Traceback (most recent call last):
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/connection.py", line 611, in connect
    sock = self.retry.call_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/retry.py", line 51, in call_with_retry
    raise error
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/retry.py", line 46, in call_with_retry
    return do()
           ^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/connection.py", line 612, in <lambda>
    lambda: self._connect(), lambda error: self.disconnect(error)
            ^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/connection.py", line 677, in _connect
    raise err
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/connection.py", line 665, in _connect
    sock.connect(socket_address)
TimeoutError: [Errno 60] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 104, in <module>
    main()
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 19, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 72, in new_site
    frappe.init(site=site, new_site=True)
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 247, in init
    setup_module_map()
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1515, in setup_module_map
    local.app_modules = _cache.get_value("app_modules")
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 87, in get_value
    val = self.get(key)
          ^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/commands/core.py", line 1705, in get
    return self.execute_command("GET", name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/client.py", line 1235, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/connection.py", line 1387, in get_connection
    connection.connect()
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/connection.py", line 615, in connect
    raise TimeoutError("Timeout connecting to server")
redis.exceptions.TimeoutError: Timeout connecting to server

I have tried to be explicit about the command, but I am not sure I have the correct arguments on the CLI. I have tried:

bench new-site --no-mariadb-socket --db-name _erpnext2023 --db-type mariadb --db-host 127.0.0.1 --db-port 3306 --db-root-username root --db-root-password XXXXXX --verbose my.site.name

That did not give any joy.

On my FreeBSD server, mysql/mariadb socket is /tmp/mysql.sock, but it also listens on all interfaces on port 3306:

root@gw:/usr/home/wash # sockstat -l | grep :3306
mysql    mariadbd   26637 22 tcp4   *:3306                *:*

I also have redis-server running:

root@gw:/usr/home/wash # sockstat -l | grep redis
redis    redis-serv 69013 6  tcp4   127.0.0.1:6379        *:*
redis    redis-serv 69013 7  tcp6   ::1:6379              *:*

If the --verbose option ‘could speak’, then I would be able to figure it out. Unfortunately it does not.

[frappe@gw ~/frappe-bench]$ bench new-site --verbose
Usage: bench  new-site [OPTIONS] SITE
Try 'bench  new-site --help' for help.

Error: Missing argument 'SITE'.
[frappe@gw ~/frappe-bench]$ bench new-site --verbose my.site.name

Then the error is the same:

File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/redis/connection.py", line 615, in connect
    raise TimeoutError("Timeout connecting to server")
redis.exceptions.TimeoutError: Timeout connecting to server

SOS!

sites/common_site_config.json has keys that point to redis and db hosts.

db_host if not specified should take localhost. it should work without any problem as long as you’ve Frappe specific Mariadb cnf setup.

for redis it looks for 3 redis servers on ports 11000, 12000, 13000, you need to start redis on these 3 ports. check how bench procfile or supervisor config does it.

1 Like

The clue about running redis-servers on ports 11000, 12000 and 13000 has helped me move to the next step. I also appreciate the hint about sites/common_site_config.json has keys that point to redis and db hosts.

After lots of reading and trials and errors, I have managed to successfully create a site on FreeBSD.

The problem is that using User ‘root’ doesn’t seem possible on FreeBSD. Using any other User seems to work if they have the right privileges.
It would seem like pymysql on FreeBSD prohibits the invocation of commands as MySQL User ‘root’.
So how did I do it?
I created an alternative MariaDB User with all privileges as root.

CREATE user `admin`@`localhost` IDENTIFIED BY 'ADMINUSERPASS';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
GRANT PROXY ON ''@'%' TO 'admin'@'localhost' WITH GRANT OPTION;

I realized earlier in my tests that pymysql hates localhost on FreeBSD. The option is to let the User to connect via a UNIX socket instead. You do that by providing '–db-host ‘’ ’ on the CLI.

This now what happened:

(env) [frappe@gw ~/frappe-bench]$ bench new-site  --db-host '' --db-root-username admin --db-root-password  ADMINUSERPASS --verbose erpnext.mysite.name
Created user _ac348d54ce483477
Created database _ac348d54ce483477
Granted privileges to user _ac348d54ce483477 and database _ac348d54ce483477
Starting database import...
Imported from database /opt/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/framework_mariadb.sql

Installing frappe...
Updating DocTypes for frappe        : [========================================] 100%
Set Administrator password:
Re-enter Administrator password:
Updating Dashboard for frappe
erpnext.mysite.name: SystemSettings.enable_scheduler is UNSET
*** Scheduler is disabled ***
(env) [frappe@gw ~/frappe-bench]$

I hope this helps fellow FreeBSD users.

disable Unix socket plugin for mariadb and try again

admin@localhost [mysql]> SELECT USER,plugin,host,ssl_type FROM mysql.user WHERE User='root';
+------+-----------------------+-----------+----------+
| User | plugin                | Host      | ssl_type |
+------+-----------------------+-----------+----------+
| root | mysql_native_password | localhost |          |
+------+-----------------------+-----------+----------+
1 row in set (0.001 sec)

Then I tried your advise:

admin@localhost [mysql]> UPDATE user SET plugin = "" WHERE user = "root";
ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

Anyway, I managed to get to the development status and did login to the site.

I am now working on getting it to production.

PS: There is a bit of confusion regarding redis-server as compared to Linux. On my Debian VM, I did not have to manually ensure that I have redis-server running on those 3 ports for me to proceed with any command. On FreeBSD, I have to, even at the stage of enable-scheduler.

I have a running instance - in production, but using Apache instead of Nginx.
Are there any known repercussions for using Apache as the webserver instead of Nginx?