<p>Probably the database doesn't listen for connections from the outside world. So yeah you'd need some kind of an ssh tunnel to connect to it. I think you may find, though, that doing development via a remote db can be pretty slow; check out <a href="https://nystudio107.com/blog/database-asset-syncing-between-environments-in-craft-cms" rel="nofollow noreferrer">Database &amp; Asset Syncing Between Environments in Craft CMS</a></p>

CC BY-SA 4.0
2018-12-29T01:02:46.873Z
Thanks for this answer Andrew. I have been using your craft-scripts to synch and it has been working well. The issue I've been trying to solve for is that I move around in my house frequently. When I'm bored with developing in my office, I pick up my laptop and go elsewhere in the house or to the coffee shop. I've been trying to come up with an easier way of dealing with the disparity between my dev environments caused by two different local databases. Anyway, the workflows you outlined and the craft-scripts are a workable solution for me.
Vaughn D. Taylor
CC BY-SA 4.0
2018-12-29T02:59:29.503Z
Craft 3.1's Project Config will help with the schema side of things, anyway.
andrew.welch
CC BY-SA 4.0
2022-09-21T18:05:28.027Z
Shameless plug: We (fortrabbit) developed Craft Copy that helps our clients to up/down database local/remote quickly.

Connecting to a remote database is slow and dangerous.
Frank Lämmer
CC BY-SA 4.0
2018-12-28T22:25:33.980Z
2018-12-28T22:25:33.980Z
andrew.welch
<p>I tried using Andrew Welch's <a href="https://github.com/nystudio107/craft-connect" rel="nofollow noreferrer">craft-connect</a> plugin, but the plugin was throwing an error on the REMOTE_DB_SERVER variable. I commented the variable out in the .env file, but I still could not connect. I also tried just using the IP address of the remote server in the DB_SERVER variable.</p>

<p>What I hope to accomplish is a shared development DB which exists on a remote server. I can then connect both of my local environments to that development DB. When I know that the development DB is good to go, I will synch it with my production DB. But, I cannot sort out how to accomplish a remote DB connection with CraftCMS.</p>

<p>I can connect to my development DB using the SSH method in SequelPro (requires SSH host IP, SSH user and SSH password). I've tried replacing the DB server variable with the IP address of my server in my .env file, but that doesn't work. If I'm tunneling into the server using SSH first in SequelPro, wouldn't I also need to do the same with my connection in Craft?</p>

<database><mysql>
How to connect to a Remote DB using CraftCMS 3.1+
# How to connect to a Remote DB using CraftCMS 3.1+

(Asked by: username_0 on 2018-12-28)

I tried using Andrew Welch's [craft-connect](https://github.com/nystudio107/craft-connect) plugin, but the plugin was throwing an error on the REMOTE\_DB\_SERVER variable. I commented the variable out in the .env file, but I still could not connect. I also tried just using the IP address of the remote server in the DB\_SERVER variable.

What I hope to accomplish is a shared development DB which exists on a remote server. I can then connect both of my local environments to that development DB. When I know that the development DB is good to go, I will synch it with my production DB. But, I cannot sort out how to accomplish a remote DB connection with CraftCMS.

I can connect to my development DB using the SSH method in SequelPro (requires SSH host IP, SSH user and SSH password). I've tried replacing the DB server variable with the IP address of my server in my .env file, but that doesn't work. If I'm tunneling into the server using SSH first in SequelPro, wouldn't I also need to do the same with my connection in Craft?

**Tags:** database, mysql

---

## 1 answers

### Answer by username_1 on 2018-12-28. Score: 2 | Accepted answer

Probably the database doesn't listen for connections from the outside world. So yeah you'd need some kind of an ssh tunnel to connect to it. I think you may find, though, that doing development via a remote db can be pretty slow; check out [Database & Asset Syncing Between Environments in Craft CMS](https://nystudio107.com/blog/database-asset-syncing-between-environments-in-craft-cms)

> **Comments:**
> **username_0**: Thanks for this answer Andrew. I have been using your craft-scripts to synch and it has been working well. The issue I've been trying to solve for is that I move around in my house frequently. When I'm bored with developing in my office, I pick up my laptop and go elsewhere in the house or to the coffee shop. I've been trying to come up with an easier way of dealing with the disparity between my dev environments caused by two different local databases. Anyway, the workflows you outlined and the craft-scripts are a workable solution for me.  
> **username_1**: Craft 3.1's Project Config will help with the schema side of things, anyway.  
> **username_2**: Shameless plug: We (fortrabbit) developed Craft Copy that helps our clients to up/down database local/remote quickly.  Connecting to a remote database is slow and dangerous.  

---

