Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
xdebug connection refused to Docker container

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 ?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

This is how I setup recently docker + php + xdebug for http-services. I guided my peers through it and it worked out flawlessly.

1. Add ENV PHP_IDE_CONFIG into your docker fpm pool config

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"

2. Add xdebug.ini to your docker container

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

3. [IntelliJ IDEA or PHPStorm] - Setup PHP servers

  1. Open Preferences
  2. Go to Languages & Frameworks -> PHP -> Servers
  3. Set Name to localhost (It's important and should match PHP_IDE_CONFIG value)
  4. Set Host to localhost
  5. Enable use path mappings
  6. Map your project root path to the docker workdir (e.g. /var/www/html) so IntelliJ can correctly map the paths.

4. [IntelliJ IDEA or PHPStorm] - Setup IDE key

  1. Open Preferences
  2. Go to Languages & Frameworks -> PHP -> Debug -> DGBp proxy
  3. Set IDE key to PHPSTORM

5. Add XDEBUG_SESSION=PHPSTORM to your url/cookie..

Finally:

  • add a ?XDEBUG_SESSION=PHPSTORM to your url OR
  • add a cookie with the name XDBEUG_SESSION and the value PHPSTORM
over 4 years ago · Santiago Trujillo Report

0

Issue was in: environment:

- XDEBUG_CONFIG:remote_host=host.docker.internal remote_enable=1 remote_autostart=off xdebug.idekey=PHPSTORM
  1. it's not correctly parsed.
  2. if i pass only remote_host=host.docker.internal then it will pass "localhost" instead of host IP address.
over 4 years ago · Santiago Trujillo Report

0

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) -

  1. Pass IP address of your host (192.168...) instead of host.docker.internal
  2. Configure pathMappings in your debug launch configuration -
{
    "name": "Debug Docker",
    "type": "php",
    "request": "launch",
    "port": 9000,
    "pathMappings": {
        "/var/www/app": "${workspaceFolder}"
    }
},

Replace /var/www/app with your own path!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!