error:
2020/04/26 23:43:48 [error] 8#8: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.208.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://192.168.208.3:9000", host: "127.0.0.1", referrer: "http://127.0.0.1/"
Cannot make connection with xdebug. Docker configuration was taken from here https://gitlab.com/martinpham/symfony-5-docker/-/tree/master/docker
xdebug was installed separately and it's recognized by IDE.
Also added this in docker-compose.yml under php-fpm environment:
environment:
- XDEBUG_CONFIG:remote_host=host.docker.internal remote_enable=1 remote_autostart=off xdebug.idekey=PHPSTORM
What else needs to be added/modified?
This is how I setup recently docker + php + xdebug for http-services. I guided my peers through it and it worked out flawlessly.
You need to add this environment into your php-fpm pool config. It could be www.conf
(as an example)
env[PHP_IDE_CONFIG] = "serverName=localhost"
Here is an example of the xdebug.ini which I used for the setup:
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = off
xdebug.remote_host = host.docker.internal
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
xdebug.max_nesting_level = 1500
Preferences
Languages & Frameworks
-> PHP
-> Servers
PHP_IDE_CONFIG
value)use path mappings
/var/www/html
) so IntelliJ can correctly map the paths. Preferences
Languages & Frameworks
-> PHP
-> Debug
-> DGBp proxy
Finally:
?XDEBUG_SESSION=PHPSTORM
to your url ORXDBEUG_SESSION
and the value PHPSTORM
Issue was in: environment:
- XDEBUG_CONFIG:remote_host=host.docker.internal remote_enable=1 remote_autostart=off xdebug.idekey=PHPSTORM
I know the post is for PHPStorm users, but if any VSCode users stumble upon here then two things that need to be done different to PHPStorm (More in this answer for PHPStorm https://stackoverflow.com/a/61561910/3056278 ) -
host.docker.internal
{
"name": "Debug Docker",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www/app": "${workspaceFolder}"
}
},
Replace /var/www/app
with your own path!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.