I am trying to debug Laravel code on Visual Studio Code using Xdebug. I am using Docker container that works as server.
But I am getting this error when try to debug:
Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 192.168.99.100:9000).
Here is my VSCode launch.json
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Docker: Attach to Node",
"port": 9000,
"address": "192.168.99.100",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/var/www",
"protocol": "inspector",
"restart": true
}
]
Here is docker-compose.yml
app:
build:
context: ./
dockerfile: .docker/app.dockerfile
args:
- INSTALL_XDEBUG=true
working_dir: /var/www
volumes:
- ./:/var/www
environment:
- "DB_PORT=33061"
- "DB_HOST=192.168.99.100"
- XDEBUG_CONFIG=remote_host=192.168.99.100 remote_port=9000 remote_connect_back=0
Here is my app.dockerfile
FROM php:7.1-fpm
RUN docker-php-ext-install pdo && docker-php-ext-install pdo_mysql
#####################################
# xDebug:
#####################################
ARG INSTALL_XDEBUG=true
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
# Install the xdebug extension
pecl install xdebug && \
docker-php-ext-enable xdebug \
;fi
# Copy xdebug configration for remote debugging
COPY .docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
#####################################
# ZipArchive:
#####################################
ARG INSTALL_ZIP_ARCHIVE=false
RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \
# Install the zip extension
docker-php-ext-install zip \
;fi
# RUN apt-get update && apt-get install -y \
# freetds-bin \
# freetds-dev \
# freetds-common \
# libct4 \
# && docker-php-ext-install pdo_dblib
# pdo_dblib
RUN apt-get update && apt-get install -y freetds-dev
RUN docker-php-ext-configure pdo_dblib --with-libdir=/lib/x86_64-linux-gnu
RUN docker-php-ext-install pdo_dblib
RUN sed -i "s|\[sqlsrv\]|\[sqlsrv\]\nhost = 172.18.250.57\nport =1435\nclient charset=UTF-8\ntds version = 8.0|g" /etc/freetds/freetds.conf
RUN usermod -u 1000 www-data
WORKDIR /var/www
CMD ["php-fpm"]
EXPOSE 9000
EXPOSE 9001
I think VSCode can't connect to remote Xdebug with 9000 port. But when check to app docker image Xdebug is working properly. Maybe VSCode needs some more configuration. But I couldn't solve this issue.
192.168.99.100? Is this a container IP or host machine? It has to be the host .. as it's xdebug that connects to VSCode 2) Do not expose 9000 port. This prevents VSCode from listening for incoming xdebug connections .. as port is occupied by Docker. 3) Get some manual specific to Docker + VSCode + Xdebug and follow it -- proper manual should have all steps listed and explained.