Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Need help connecting to external maria db from erpnext running in docker

I am trying to launch erpnext with docker on production, I have kept database in separate server.

Provided the database server ip in .env file MARIADB_HOST=1.1.0.1
when erpnext server runs, it appends port twice.

Attempt 1 to connect to 1.1.0.1:3306:3306

Mariadb is on docker host machine?

Use IP 172.17.0.1

You’ll need to add % as host for root user and existing db users that access db from containers

Hi @revant_one
I have a different server running maria db in docker. Port is attached to local port.
docker run -d -p 3306:3306 mariadb:version.

I am able to connect to mysql server from another server

mysql -h 1.1.0.1

issue is erpnext trying to connect to
1.1.0.1:3306:3306

Something to do with networking, firewall?

I have a VPS with mariadb hosted, I use it from my containers. I’m able to connect and use it.

I had to allow cluster ips to connect to mariadb host and it worked.

So the problem is that the port is getting added twice, if not I am able to connect to the database from outside.

1.1.0.1:3306:3306

MARIADB_HOST needs to be ip only.

Check the common_site_config.json.

db_host and db_port are separate keys

1 Like

@revant_one
When I first started the container, I had provided 1.1.0.1:3306 as the MARIA_DB host. This was stored in the volume, I removed the volume and restarted it started establishing the connection.

Hi @revant_one
my user is root

erpnext-python_1 | Attempt 1 to connect to 1.1.0.1:3306
erpnext-python_1 | Attempt 1 to connect to redis-queue:6379
erpnext-python_1 | Attempt 1 to connect to redis-cache:6379
erpnext-python_1 | Attempt 1 to connect to redis-socketio:6379
erpnext-python_1 | Connections OK

when I make request to erpnext-python_1, it throws error.

pymysql.err.OperationalError: (1045, “Access denied for user ‘_559c5fa6381378f2’@‘1.1.0.1’ (using password: YES)”)

Db needs to allow access to wildcard (%) as host

Refer https://github.com/frappe/frappe_docker/tree/develop/development#fixing-mariadb-issues-after-rebuilding-the-container

thanks @revant_one that helped.

Interestingly, data tables are not getting created.
pymysql.err.ProgrammingError: (‘DocType’, ‘Portal Menu Item’)

Can I manually run these migrations?

yes you can try that. enter into erpnext-python container and exec bench --site <site> migrate

1 Like

getting this error. database is empty
pymysql.err.ProgrammingError: (1146, “Table ‘_559c5fa6381378f2.tabDefaultValue’ doesn’t exist”)

try to create site again. if you have created the site using “new” erpnext-python container command then it should work, if you create site with bench new-site use --no-mariadb-socket