I installed NocoDB in my local server attached to an instance of MySQL (actually MariaDB) and it runs terrific when I’m connected form my laptop using postman, which means API is working and accessing data.
But when I try to add a data source (using Connect to External Data), for NocoDB to access another schema on the same MySQL instance, I can’t create a new connection to the database. It keeps telling me “Connection Failure:”. I’m using localhost for the Host address, 3306 for the Port number, and the user name and password I setup directly on MySQL.
I tested successfully the credentials on the terminal of the server using the command “mysql -h localhost -P 3306 -u -p” and entering the password. So I’m kind of lost. I’m pretty sure the issue is something silly …
If you are using localhost external source, you will have to set the following environment variable to true
“NC_ALLOW_LOCAL_EXTERNAL_DBS=true”
Connecting to localhost by default is disabled.
I’m running NocoDB using docker, following the general recommendations. So, should I add the variable just as in “docker run -e NC_ALLOW_LOCAL_EXTERNAL_DBS=true …” ?
Is there another way to verify the variable was properly set?
Cheers,
That’s correct. You just have to set it up using -e
option
Still facing issue connecting to external source?
Unfortunately, yes…
The same error (with no description).
If you are running mysql also as docker, you will have to use “host.docker.internal” instead of “localhost” as host address. Please confirm if this is the case.
Mmmh… Nope, I’m only running NocoDB in a docker.
Hi @Jllerena
You still need to use host.docker.internal
(or if you are using linux 172.17.0.1
as alias will not be added by default in linux).
Because localhost
will target container itself but you want to target host of the container.