Switching to production mode breaks Erpnext (404 errors)

This is how I’m trying to install erpnext on my vps running Ubuntu 22.04 LTS:

Add a new user

sudo adduser erpadmin
sudo usermod -aG sudo erpadmin
su - erpadmin

1. Update your system (Ubuntu)

sudo apt update && sudo apt -y full-upgrade

Now reboot:

sudo reboot

2. Install GIT

sudo apt-get install git

3. Install pythonc api

sudo apt-get install python3-dev

4. Install PIP and Setuptools for python

sudo apt-get install python3-setuptools python3-pip

5. Install virtual environment for python

sudo apt-get install virtualenv

6. Install MariaDB

sudo apt-get install software-properties-common
sudo apt install mariadb-server

7. Setup MariaDB’s root password and other settings

sudo mysql_secure_installation
$ Enter current password for root (enter for none): press enter here
$ Switch to unix_socket authentication [Y/n] n
$ Change the root password? [Y/n] y
$ New password: *enter your password here*
$ Re-enter new password: *enter your password here again*
$ Remove anonymous users? [Y/n] y
$ Disallow root login remotely? [Y/n] n
$ Remove test database and access to it? [Y/n] y
$ Reload privilege tables now? [Y/n] y

8. Install MYSQL C development library

sudo apt-get install libmysqlclient-dev

9. Edit MariaDB’s configuration file using nano (or vi whatever text editor you are comfortable with)

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add the following to the file:

[server]
user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
bind-address = 127.0.0.1
query_cache_size = 16M
log_error = /var/log/mysql/error.log

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

Now these find these lines in the file, it should be under # * Character sets and comment them out using # :

# character-set-server  = utf8mb4
# collation-server      = utf8mb4_general_ci

Press Ctrl+S to save the edited file and Ctrl+X to exit.

Now restart MYSQL again:

sudo service mysql restart

10. Install Redis server

sudo apt-get install redis-server

11. Install Node.js 14.X

sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 
source ~/.profile
nvm install 14.15.0

12. Install NPM and Yarn (package managers)

sudo apt-get install npm
sudo npm install -g yarn

13. Install wkhtmltopdf

sudo apt-get install xvfb libfontconfig wkhtmltopdf

14. Install Bench

sudo -H pip3 install frappe-bench
bench --version

15. Initialize Bench

bench init frappe-bench 

16. Create your site for Bench and set it as the default site for Bench

cd frappe-bench/
bench new-site erp.mysite.com
bench use erp.mysite.com

17. Install Erpnext your Bench site

bench get-app erpnext
bench --site erp.mysite.com install-app erpnext

18. Start your Bench and migrate your site

bench start
bench migrate

Now everything works fine in development mode and I am able to login normally but when I try to switch to production mode, I run into multiple errors:

First I try normally switching to production mode using:

sudo bench setup production erpadmin

and it worked without any errors, then I ran:

bench restart

which returned:

$ supervisorctl restart frappe:
frappe: ERROR (no such group)
frappe: ERROR (no such group)

So I thought of rebooting my vps and trying again and unfortunately it didn’t work so I tried manually rebooting the vps from my dashboard and re-running bench restart and once again it threw up the same error.

Then I tried these following commands:

bench setup supervisor
sudo supervisorctl reread
sudo supervisorctl reload
sudo supervisorctl restart all

and I keeps throwing up the same frappe: ERROR (no such group) error.

The site (my ip without the 8000 port) was showing this:

I finally rebooted my vps again ran bench restart again and it threw up the same error but when I checked my site again:

I have been pulling my hair out trying to fix this production mode issue for the last week.
I am guessing this is a nginx config issue since the site is unable to pull some of the resources in the error logs as it seems?

HELP :sweat:

Hi,

Try bench build , then bench update

What does bench version return?

1 Like

bench build and bench update ran without any hitch but did not do anything for me

erpnext 14.x.x-develop
frappe 14.x.x-develop

still the same :sweat:

Since it is version 14, and still beta, that feature may not be implemented , although I believe some may have it running in production, perhaps by other means. @peterg ?

Thanks it didn’t even cross my mind once. I’ll hit this thread up with an update after I downgrade.

How do I install a specific version of erpnext/frappe? Currently I’m using sudo -H pip3 install frappe-bench and bench get-app erpnext, bench --site erp.mysite.com install-app erpnext to install the respective packages.

You can try bench switch-to-branch version 13 frappe erpnext. See bench switch-to-branch --help

To install a specific branch at the outset , best to bench get-app --branch version-xx erpnext then install it to the site.

In Frappe, “Production” isn’t a version-specific feature. It means that you’ve got nginx as a reverse proxy and supervisor as a process manager.

From the error messages being shown, I suspect that the system has misconfigured permissions. The place to check would be supervisor and nginx logs.

I successfully migrated to version 13 but since then every bench command fails with some traceback errors so I went through a fresh install and I tried manually installing erpnext 13 and when I run bench get-app --branch version-13 erpnext it got stuck at Installing erpnext. I waited for like 2 hours straight and then gave up. bench get-app erpnext runs fine I don’t know why being branch specific is giving me so much trouble.

1 Like

The get-app or install-app --site erpnext hangs?
What does bench version return?

It hangs only if I’m being version specific like bench get-app --branch version-13 erpnext or bench init --frappe-branch version-13 myfrappe

So when bench get-app --branch version-13 erpnext hangs I just decided to wait for like 30 minutes (since I get no form of response from the console) and restarted my terminal and checked the bench version

erpnext 13.32.0
frappe 13.31.0

I decided to go forward with the installation the bench start was running on 0.0.0.0:8000 as opposed to <my ip address>:8000, I couldn’t open it since I’m using a vps, I proceeded to switch to production mode with sudo bench setup production erpadmin and once again the website came up with the same broken 404 page.
I am now fully convinced that this is a nginx issue and very close to giving up.

You may also try to set maintenance mode off

What does bench setup nginx return?

$ bench setup nginx
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Port configuration list:

Site erp.mysite.com assigned port: 80

This did not do anything unfortunately

Are you seeing the Your system is being updated message or 404. If the site is on port 80, not 8000 then the 404 would result, I think.

Only the 404. 80 is the default port right?? I have seen everyone’s installation and port 80 is just your IP address (which is the way it should be when you switch to production mode I’m assuming).

I even tried changing the default port to
bench set-nginx-port erp.mysite.com 8090

<my ip address>:8090 was showing the exact same 404 Sorry! We will be back soon page page.