Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jjamesschuler's avatar

Connect to Digital Ocean DB from Local Homestead

I have had great success with using Forge and Homestead, but on a current project I need to connect my local Homestead install to the DO DB, but I cant get it to connect. Navicat works using SSH but unsure how to do it for a regular app connection... Anyone know how? Thanks

0 likes
2 replies
fideloper's avatar

Navicat works using SSH because it creates an SSH tunnel. You can do this manually from Homestead as well.

I'm assuming you're using MySQL, but let me know if you're using PostgreSQL.

From within the homestead server, run this SSH command:

ssh -L 3333:localhost:3306 username@hostname

This forwards your local port 3333 to your digitalocean server's "localhost:3306" socket, which MySQL will be listening on.

You'll need to change your username/hostname for however you connect over SSH to your DO server.

Then in your application configuration, use localhost and port 3333 to connect to the remote database.

Some more information here with explanation under Local Port Forwarding: https://serversforhackers.com/ssh-tricks/

jjamesschuler's avatar

Thats awesome...that is what I was talking about, although how would I accomplish having multiple different servers with different DBs. I.E. if I need to connect to server A Database B, and on another site connect to Server C Database A How can I manage those multiple connections on a site by site basis?

Please or to participate in this conversation.