How to set database connection when host denies access from outside?

I’m ready to publish my website onto my server. The problem is, my hosting provider doesn’t allow access to the database from outside the server environment (security reasons). Basically, no problem since the website runs on the same server. But Wappler doesn’t save a database connection when the connection is not tested before. So I can’t save my database connection since it’s a connection timeout.

If there is no Wappler way, I’m gonna try to set a static IP on the server to enable access:

You don’t need a remote access (access to the database from outside the server environment).
All you need is to setup a target pointing to your server, and upload the site there.

Wappler database connection works the following way:

  1. When you save the server action the server action and connection file are being pushed to the server (to the selected target)
  2. The connection file is then being called from your target and the connection is done from there (from your server).

That’s why no need to setup a remote connection - just a target on your real server.

Hm I’ve already created the remote target which works fine, the site is already uploaded. But I don’t quite understand how this eliminates the connection timeout. The problem is, I can’t even change the database connection to my database since it doesn’t allow me to save. Am I missing something crucial here?

Ok so if the action file is executed from the server, there is another reason the database can’t be found. I’m gonna examine the server and see if I can find something.

If only it was that simple Teodor, if you cannot get remote access you can’t save the server connection details to upload. It’s a big issue I have discussed with George before and there is a feature request to allow alternative server settings to be input.

@jowhiskey my current workaround is to create a local database with the same database name, username and password
I then edit the hosts file on my local machine and divert the online database url to my local mysql server. Bit of a hack but it works.

1 Like

Are you using CPanel/WHM? If so maybe you can add further MYSQL Hosts? Some hosting companies allow this. You can find this option in CPanel / Databases / Remote MySQL (and add your server IP).

Or maybe go with localhost on both the testing server and the remote server then that way there are no configuration issues?

Or you could manually edit the DMX Connection file on the remote server to localhost? Assuming the site is hosted on the same server as the database?

1 Like

The files itself are all being uploaded via ftp. So that part works. But as you said, the database connection is uploaded with the old parameters from localhost since I can’t change them.
It would help already to be able to save database connections without automatically testing the connection when saving. So the file can be uploaded with the right parameters.

That is an option. Either that or changing the parameters manually in dmxConnection as @Dave stated.
It is unfortunate to undertake such inconveniences because hosting providers don’t see fit to just add a config panel where a temporary database connection from a local machine can be opened.

If you are using CPanel you can do this depending on the host:

No doesn’t use CPanel as far as I can tell. Their approach is to call their support and tell them they should add a static IP.

Perfect. I changed the parameters directly in the file and it works perfectly now! Thank you @Dave for this hint!
@Teodor it would be useful to disable automatic connection test when saving. There already is a “Test connection” button which should suffice.

1 Like

Am happy to have helped. More often than not finding a work-around is a common occurrence in web-app development. No matter the software, the client, or all the best laid planning and preparation!


1 Like

Problem with disabling auto test on save is that wappler reads the database structure at that point so changes in database structure won’t be detected.

1 Like

Ok that is good to know! So it’s a matter of basic functionality rather than workflow.

Hey Brian,
Can you explain what is wrong with setting up a database connection for the selected target? I don't really understand what the issue is and what is wrong with the workflow.

Pretty much fully covered in this thread

The issue is, I can’t upload the PHP action file to the target with the right parameters because Wappler doesn’t let me save the remote database parameters when the database isn’t accessible from the computer. So it’s kind of a vicious circle.

Sorry @Teodor, this is the thread I meant to post.
Mysql connections - ISP remote connections and development to production upload setting changes

Just by the way, if anybody uses StackPath as a content delivery network you will find the same issue, the only way around it is to add the IP into the cPanel Remote SQL Connection list or you can not gain access and vice versa, you also have to go into StackPath and add the IP of your remote server into their Allow List in the firewall or it will not play nice at all.

1 Like