Error Migrating ERPNext from Version 3 to 4

Hi ,
I am trying to migrate version 3 hosted in VM to version 4 by following the migration guide found here Migrating from ERPNext version 3 · frappe/bench Wiki · GitHub

all the steps went smoothly and reached the section -

Install bench

cd /home/erpnext
git clone GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps bench-repo
sudo pip install -e bench-repo
Setup ERPNext on the new bench

cd ~
bench init frappe-bench
cd frappe-bench

but after than when i execute his migration command like -
bench migrate-3to4 /path/to/old/erpnext/folder with chaning my old erpnext folder location it is giving following error . Kindly help. :frowning:

bench migrate-3to4 /home/erpnext/erpnext/
Traceback (most recent call last):
File “/home/erpnext/bench-repo/bench/”, line 106, in
File “/home/erpnext/bench-repo/bench/”, line 38, in main
site = copy_site(path)
File “/home/erpnext/bench-repo/bench/”, line 49, in copy_site
raise Exception(“Site already exists”)
Exception: Site already exists
Error: None
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==0.1’, ‘console_scripts’, ‘bench’)()
File “/home/erpnext/bench-repo/bench/”, line 29, in cli
return bench()
File “/usr/local/lib/python2.7/dist-packages/click/”, line 610, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 590, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 936, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/”, line 782, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 416, in invoke
return callback(*args, **kwargs)
File “/home/erpnext/bench-repo/bench/”, line 162, in migrate_3to4
File “/home/erpnext/bench-repo/bench/”, line 59, in exec_cmd
subprocess.check_call(cmd, cwd=cwd, shell=True)
File “/usr/lib/python2.7/”, line 511, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘env/bin/python /home/erpnext/bench-repo/bench/ /home/erpnext/erpnext/’ returned non-zero exit status 1

Did you check if you are not migrating to an existing site?

The command should be
bench migrate-3to4 /home/erpnext/erpnext/

I have an ERP version 3 Running in the same Virtual Box and trying to migrate this to frappe-bench.
I am executing the same command
bench migrate-3to4 /home/erpnext/erpnext/
See the screenshot:

Inline image 1

can you try it without the leading slash?
bench migrate-3to4 /home/erpnext/erpnext

You were right , removing the leading slash worked .

Earlier the error message was Site Already exist but now i am getting this :

ImportError: No module named erpnext.hooks

Please Help.

Inline image 1

Have you installed the erpnext app in the bench?

bench get-app erpnext             # Add ERPNext to your bench apps
bench get-app shopping_cart # Add Shopping cart to your bench apps
1 Like

Oooops I missed that…

after installing the bench and running the migrate script i got this:

_mysql_exceptions.OperationalError: (1051, “Unknown table ‘erpnext.tabWebsite Route’”)

Inline image 1

Please Help… I am stuck and can not migrate to ERPNext 4.

Can you comment the line that drops that table in the patch and try again?

I commented that line and the migration goes well. The message said migration completed.

which means i followed the steps given in this link


Migrate you site to the new bench

bench migrate-3to4 /path/to/old/erpnext/folder
Now should i follow the further steps ????

Continue with production deployment

or the new site is good to go ?

As i rebooted the VM after the upgrade and the old ERPNext link says "Internal server error "

I also tried running bench start which gave this :

Inline image 1

If you have completed production deployment, ERPNext is started on boot and bench start is no longer required. check if it’s running on port 80 (curl localhost)

curl localhost says

could not connect to host.

You mean to say that after the migration is done i need to follow the instructions given here :

If yes then i followed the steps mentioned here and able to setup supervisor but when i am setting up Nginx it gives error :

bench setup nginx
sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe.conf

Inline image 1

Moreover i dont find any location like /etc/nginx/conf.d

Is Nginx installed already with the VM ERPNext 3 or i will to manually install it ?

Oh, I think you’ll have to install nginx. Didn’t know that you’re using the version 3 VM. You’ll have to configure port forwarding also. Something like,

@3ddeveloper might be interested in this config too.

Sorry for the long gap as was out for vacations.

Earlier enginx service was not running on startup so curl localhost was giving error .Now curl localhost says :

<html> <head> <title>Internal Server Error</title> </head> <body> <h1>Internal Server Error</h1>


Moreover netstat -anp|grep :80 givestcp 0 0* LISTEN 3344/nginxtcp 0 0* LISTEN 2098/pythontcp 0 0 TIME_WAIT -tcp 0 0 TIME_WAIT -tcp 0 0 TIME_WAIT -tcp 0 0 TIME_WAIT -

As you mentioned in your last message that i will have to use port forwarding , could you please guide me how to do that port forwarding , Will i have to do this on my router or in the VM machine ?

Please check the logs at /home/erpnext/frappe-bench/logs/web.error.log to see what’s wrong.

Also, you will have to configure Port Forwarding in VM Settings,

The error logs at /home/erpnext/frappe-bench/logs/web.error.log is empty .

Moreover i am using a bridged interface in Vbox , so do i need to still use this port forwarding ? Port forwarding option only available when the interface is on NAT.

Port forwading is not required in bridge mode.

Can you see nginx logs, /var/log/nginx/error.log?