Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp-now: Error establishing database connection when 'DB_HOST' is 'localhost' #18

Open
danielbachhuber opened this issue May 17, 2023 · 3 comments
Labels

Comments

@danielbachhuber
Copy link
Member

define( 'DB_HOST', '127.0.0.1' ); works as expected. However, define( 'DB_HOST', 'localhost' ); produces this error:

image

From WordPress/wordpress-playground#360 (review)

Done is:

  • wp-now can connect to a MySQL database on 'localhost'
@adamziel
Copy link
Collaborator

adamziel commented May 17, 2023

Does it work with define( 'DB_HOST', 'localhost:<port>' );? If it's just localhost, PHP will try to use a unix socket (which lives in /var/run/mysqld/mysql.sock by default) instead of connecting over the network. Perhaps mounting /var in the VFS would do the trick?

@danielbachhuber
Copy link
Member Author

Does it work with define( 'DB_HOST', 'localhost:<port>' );?

Nope.

Perhaps mounting /var in the VFS would do the trick?

Should we mount the entirety of /var, or simply /var/run/mysqld/?

@adamziel
Copy link
Collaborator

adamziel commented May 17, 2023

For now the latter will do. Later on we might need access to more unix socket to support other PHP extensions. All of this hinges on Emscripten's ability to communicate through these sockets, though. If it cannot easily do it, we'll need to find a way to always trigger the network mode

It is weird that it doesn't work with the port, though. I wonder if WordPress strips before passing the host string as an argument somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants