Switching to production mode breaks Erpnext (404 errors)

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.

I’m facing the exact issue for about two weeks!
The page seems loaded without CSS on port 80 after sudo bench production frappe command!
Someone help us here PLEASE!
I’m on version 13.32.0

By the way, you have the error 404 because supervisor is not working, try to start the services for both (nginx & supervisor)

sudo service nginx start
sudo service supervisor start

But unfortunately, that will not solve the CSS issue!

Like I mentioned earlier in the thread, the missing css is likely a permissions issue. Check your nginx logs.

Thank you @peterg
In fact, I’m not a developer, so I struggle a lot when you just mention a “permissions issue”, I don’t know how to fix it nor how to check it!

I found the following answer which seems have solved the problem with CSS:

but a new error arised:
image

after copying the error, here is the result:

### App Versions

{
	"frappe": "13.32.0"
}

### Route

setup-wizard/0

### Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 38, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 76, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1448, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/page/setup_wizard/setup_wizard.py", line 282, in load_messages
    m = get_dict("page", "setup-wizard")
  File "apps/frappe/frappe/translate.py", line 207, in get_dict
    message_dict = make_dict_from_messages(messages, load_user_translation=False)
  File "apps/frappe/frappe/translate.py", line 243, in make_dict_from_messages
    full_dict = load_lang(frappe.local.lang)
  File "apps/frappe/frappe/translate.py", line 302, in load_lang
    path = os.path.join(frappe.get_pymodule_path(app), "translations", lang + ".csv")
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'


### Request Data

{
	"type": "POST",
	"args": {
		"language": "English"
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.page.setup_wizard.setup_wizard.load_messages"
}

### Response Data

{
	"exception": "TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'"
}

Moreover, I noticed the following log when executing cat ~/frappe-bench/logs/web.error.log is that normal?


I finally give up and dropped my site to create a new site and it is working well

Can you explain how to fix the css issue? I am unable to decipher the answer you linked

  • edit /etc/nginx/nginx.conf and add into the http { section: disable_symlinks off;
  • remove both symlinks and use bind in /etc/fstab, for example:
    /opt/erpnext/frappe-bench/apps/erpnext/erpnext/public /opt/erpnext/frappe-bench/sites/assets/erpnext none defaults,bind 0 0

What does “removing symlinks” and “use bind” even mean? I looked for both the terms inside nginx.conf and I couldn’t find them (could you please link them). Also there was no folder named “fstab” in /etc/fstab.

I didn’t do that part, I just changed the user that nginx use by commenting the first line and adding another one with my frappe user. Moreover, I added the disable_symlinks off; under http {} section. Then restarted the nginx service and it’s just work!
Later on, I found a command which seems to do the last part of fstab thing which I didn’t do because I didn’t understand it very well, and here it is:

bench build --hard-link

and here is a screenshot of my nginx.conf file:
image

3 Likes

only need to change /etc/nginx/nginx.conf with above changes and its good to go!
thanks

This helped a lot. Thanks @adelalmajed