Running PhpStorm on Windows 10. PostgreSQL is on my WSL instance of Ubuntu 20.04.
Trying to connect to the IP that is found by using wsl hostname -I
using the built in Database interface/browser in PhpStorm.
Is there a different port or setting I am suppose to use? Thank you!
My Answer:
To connect to PostgreSQL running on your WSL instance from PhpStorm on Windows 10, you need to make sure that PostgreSQL is configured to accept remote connections and that the necessary firewall rules are in place.
Here are the steps you can follow:
1. Update PostgreSQL configuration:
- Open the PostgreSQL configuration file `postgresql.conf` located in the PostgreSQL data directory (usually `/etc/postgresql/
- Find the `listen_addresses` parameter and set it to `'*'` to allow PostgreSQL to listen on all available network interfaces.
- Save the changes and restart PostgreSQL for the changes to take effect.
2. Update PostgreSQL `pg_hba.conf` file:
- Open the `pg_hba.conf` file located in the PostgreSQL data directory.
- Add a line to allow connections from your Windows 10 IP address or subnet. For example:
host all all 192.168.1.100/32 md5
- Save the changes and restart PostgreSQL for the changes to take effect.
3. Update Windows Firewall settings:
- Allow incoming connections to PostgreSQL port (default is 5432) in the Windows Firewall settings.
4. Connect from PhpStorm:
- In PhpStorm, open the Database tool window (View -> Tool Windows -> Database).
- Click on the `+` icon and select `Data Source -> PostgreSQL`.
- Enter the necessary connection details:
- Host: Use the IP address of your WSL instance (you can find it using `wsl hostname -I`).
- Port: Use the default PostgreSQL port (5432) unless you have configured it differently.
- Database, User, and Password: Enter the credentials for your PostgreSQL database.
- Click `Test Connection` to verify the connection and then click `OK` to save the data source.
By following these steps, you should be able to connect to PostgreSQL running on your WSL instance from PhpStorm on Windows 10. If you encounter any issues, double-check the configuration settings and make sure that PostgreSQL is running and accessible from your Windows 10 machine.
Rate this post
4 of 5 based on 2508 votesComments