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

andriusbartulis's avatar

Can't connect to homestead's mysql database from host computer

For some reason I can't connect to homestead's mysql from the host of the virtual box. I could do it fine just an hour ago, and I don't remember changing any config settings. It just stopped working out of the blue.

The database works just fine, my app works fine too. Its only that I can't connect to it from my host using Sequel Pro as the connection times out.

I am definitely using the correct password and user. Didn't change the connection settings at all.

The weird thing is it worked just fine a few hours ago.

Anyone had this problem before?

By the way, if you need any logs or anything let me know. Though the connection is timing out so I don't think the data is even reaching the mysql server.

0 likes
27 replies
chrisgeary92's avatar

Are you using the correct ports? MySQL should be 33060 on homestead if you're connecting from your host machine.

1 like
andriusbartulis's avatar

Yes. I am using port 33060 at 127.0.0.1

This is quite strange. Could it be something to do with failure to bind ports by vagrant?

1 like
NikkiLoveGod's avatar

And that 172.0.0.1 was a typo and you meant 127.0.0.1 right? :)

andriusbartulis's avatar

Lol yeah I meant to say 127.0.0.1 Corrected the post.

Any other ideas?

bashy's avatar

Should be using SSH to connect?

On my Vagrant machine (not Homestead though)

4 likes
andriusbartulis's avatar

Hmm.. still timing out. I think I might have to just delete vagrant and virtual box and start from scratch. Maybe some config file got corrupted or something.

bashy's avatar

Just have to make sure you have the right usernames and passwords.

HRcc's avatar
HRcc
Best Answer
Level 22

Can you connect to mysql from homestead? If that's possible, you should be able to connect in the way bashy described. But destroy&up might be the quickest solution.

bashy's avatar

You could also try telnet into the server to check you can connect to the IP/port from outside the VM env.

andriusbartulis's avatar

Destroy and up did it. I have no idea what it was as I am sure that the credentials were definitely correct. I was really curious why it kept timing out, but then I guess no point spending too much time trying to figure this out. Though thanks for your ideas.

magpoc's avatar

It might be late but I have succeeded to connect mysql in my homestead box from my host machine(Mac). In the SSH tab of my Sequel Pro, I have set my connection settings as below.

MySQL Host: 10.0.2.15
Username: homestead
Password: secret
Database: (empty)
Port:     (empty)

SSH HOST:   192.168.10.10
SSH User:   vagrant
SSH Key:    ~/.ssh/id_rsa
SSH PORT:   (empty)

The IP address of MySQL Host is a bind address which is set in /etc/mysql/my.conf as bind-address in your homestead. Or you can confirm it by checking listening port 3306(port of MySQL) using command 'netstat -nat | grep :3306', which show up the info like this.

tcp        0      0 10.0.2.15:3306          0.0.0.0:*               LISTEN     

Other settings may change depending on your environment.

6 likes
bashy's avatar

Commenting out the bind-address will allow it to listen on all interfaces. You need that for any remote access...

magpoc's avatar

I see, so the bind-adress is not indispensable setting in the private development environment. May be that was a default settings of homestead because I do not remember that I changed the setting of bind-address by myself.

bashy's avatar

Well if it's set to the IP address of the Homestead, it will work. Just won't if it's binded to 127.0.0.1 or localhost.

shaneparsons's avatar

I'm having this issue as well, i.e. I can't connect with Sequel Pro.

Back in the day, when I first installed homestead, it didn't work.. then one day it randomly started working and did for about a month. Now it doesn't work anymore and I have no idea why as I didn't change anything.

I've tried everything on this page with no luck.. Any help would be greatly appreciated.

mwm's avatar

Had the same issue, here is how I fixed it: I added a host entry in /etc/hosts file: 192.168.10.10 homestead, then used that hostname in Sequel Pro (instead of 192.168.10.10)

Good luck

cariboufute's avatar

What I did after installing El Capitan is using this configuration.

Switch to SSH tab then add these.

Host : 127.0.0.1
username: homestead
password: secret
base: (empty)
port: (empty)

SSH Host: 192.168.10.10
SSH user: vagrant
SSH key: ~/.ssh/id_rsa
SSH port: (empty)

3 likes
shkeats's avatar

For people connecting to homestead on Windows using MySQL Workbench, the config that works for me looks like this.

Connection Method: Standard TCP/IP over SSH

SSH Hostname: 127.0.0.1:2222

SSH Username: vagrant

SSH Password: [Don't set this]

SSH Key File: C:\Users\YourUsername\Homestead.vagrant\machines\default\virtualbox\private_key (Use a search on your user directory for "private_key" if this path doesn't work for you.

MySQL Hostname: 127.0.0.1

MySQL Server Port: 3306

Username: homestead

Password: secret

Leave everything else as default and hit test connection to make sure it works.

4 likes
deepanshu27193's avatar

with default configuration on ubuntu and homestead, i am able to connect with :-

"mysql --port=33060 --host=0.0.0.0 -u homestead -p" with password "secret"

rodrigo's avatar

I ran into the same problem, in my case mysql was complaining about expired password. To fix the problem all I had to do was:

vagrant ssh
mysql -u homestead -p
SET PASSWORD = PASSWORD('secret');
lynxtdc's avatar

I recently had this happen and was able to fix it by doing the following:

Open a shell window for your vagrant box Log into mysql using the following: mysql -u homestead -p when prompted enter secret (or whatever you set as your homestead mysql password) once logged into mysql run the following command: SET PASSWORD = PASSWORD('secret') [ or what ever you'd like your mysql password to be) To test you were successful, while still logged into mysql run the SHOW DATABASES command, if you get results you should be good to go

yazeed's avatar

I was able to connect with the following settings.

Sequel Pro Settings for Homestead

kapooostin's avatar

Sequel Pro can use standard connection with these settings:

Host: 127.0.0.1
Username: homestead
Password: secret
Port: 33060

The only this you need to change is... Connection Timeout in Preferences>Network.

It took me a few hours to figure out this, though Sequel Pro always suggested that it could be an issue: «Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).»

1 like
ponnuchmay's avatar

you may connect using following line, The local host is listening port 5432, but homestead is listening 54320 port to connect.

psql -U homestead -h 192.168.10.1 -p 54320

or

psql -U homestead -h 127.0.0.1 -p 54320

1 like

Please or to participate in this conversation.