Score:0

PhpStorm Laravel trying to connect to MySQL database throws java.net.ConnectException: Connection refused: connect

co flag

I am trying to set up a laravel project in phpstorm but fail at connecting to a mysql database. These are the steps I've taken so far:

  1. download and install composer, vagrant and virtualbox
  2. create laravel/laravel project with composer (create composer project in phpstorm)
  3. integrate laravel/homestead with composer: composer require laravel/homestead --dev
  4. build homestead in root dir: vendor\\bin\\homestead make (windows)
  5. personalize my local domain by setting it in Homestead.yaml -> sites -> map: mydomain.com
  6. integrated the domain in c:/windows/system32/drivers/etc/hosts: 192.168.10.10 mydomain.com
  7. create empty ssh key for vagrant to run: fsutil file createnew C:/Users/<username>/.ssh/id_rsa 0
  8. start VM with vagrant: vagrant up

So far so good, everything seems to work. And here comes the problem:

  1. create mysql database with phpstorm's integrated database tool, using .env as reference (DB_CONNECTION=mysql, DB_HOST=127.0.0.1, DB_PORT=3306, DB_DATABASE=laravel, DB_USERNAME=root, DB_PASSWORD=devpw)

After installing drivers when trying to test connect:

[08S01]
    Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Or in the log:

java.net.ConnectException: Connection refused: connect.

I've been trying to find a fix for some time now without success. This Thread seems to provide solutions, many of which I am not sure how to implement, since they are not directed at phpstorm. I feel a bit overwhelmed by the whole backend thing and how to set it up right in laravel.

Am I supposed to install mysql on windows before integrating it into phpstorm?

Michael Hampton avatar
cz flag
Are you really trying to talk to a MySQL server that doesn't exist?!
Artur Müller Romanov avatar
co flag
It does look like it. Thanks
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.