Php_network_getaddresses getaddrinfo failed name or service not known

  • Hi team,

    Show

    After installing the plugin I get the error below:

    Warning: PHP Startup: php_network_getaddresses: getaddrinfo failed: Name or service not known in /wp-content/plugins/waterwoo-pdf/inc/tcpdi/tcpdi.php on line 112

    Warning: PHP Startup: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /wp-content/plugins/waterwoo-pdf/inc/tcpdi/tcpdi.php on line 112
    Unable to watermark this file for download. Please notify site administrator.TCPDF_PARSER ERROR: PDF data was not read, either because the file doesn’t exist, is corrupted, or transfer timed out.

    I have checked all settings and everythings is as per documentation but still not working. Any idea?

    Many thanks

    • #4

    Having this same problem with CentOS 8...

    Php_network_getaddresses getaddrinfo failed name or service not known

    • #6

    "getaddrinfo failed: Name or service not known" can have many different reasons, non only a closed port. Very frequent mistakes are malformed addresses in the function, e.g. "htp://" instead of "http://" or "http:// myaddress.com" instead of "http://myaddress.com" etc. First thing to check is whether a correct address is used.

    Adding localhost as a nameserver only makes sense if there is actually a nameserver running on the machine and it can deliver the data that is requested. I think having localhost as the only nameserver in /etc/resolv is a bad idea.

    Comments

    Description:

    mysql, redis This problem occurs under the debug of phpstorm. This problem does not occur directly in the browser or postman. I want to know what causes it.

    error

    redis
    php_network_getaddresses: getaddrinfo failed: Name or service not known [tcp://reids:6379]
    mysql
    SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

    Project configuration file .env
    redis

    REDIS_HOST=reids
    REDIS_PASSWORD=null
    REDIS_PORT=6379

    mysql

    DB_HOST=mysql
    DB_PORT=3306
    DB_DATABASE=campaign
    DB_USERNAME=root
    DB_PASSWORD=root

    docker fo mac
    dcoker:19.03
    docker-compsoe:1.25.2

    check container working first.
    docker-compse ps
    docker-compse logs mysql
    docker-compse logs redis

    Ref #2507

    Probably typo:

    REDIS_HOST=reids

    @metalcamp Not the problem, the configuration is wrong

    @pizsd: Is your redis service (in docker-compose.yml) also named reids?

    I'm getting this error too.

    Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

    when i run tests from phpstorm I'm getting this. But i didn't get this when i run from terminal like phpunit Tests\ExampleTest

    My project .env

    DB_CONNECTION=mysql
    DB_HOST=mysql
    DB_PORT=3306
    DB_DATABASE=default
    DB_USERNAME=default
    DB_PASSWORD=secret
    

    laradock .env

    MYSQL_VERSION=5.7
    MYSQL_DATABASE=default
    MYSQL_USER=default
    MYSQL_PASSWORD=secret
    MYSQL_PORT=3306
    

    docker-compose.yml

    mysql:
          build:
            context: ./mysql
            args:
              - MYSQL_VERSION=${MYSQL_VERSION}
          environment:
            - MYSQL_DATABASE=${MYSQL_DATABASE}
            - MYSQL_USER=${MYSQL_USER}
            - MYSQL_PASSWORD=${MYSQL_PASSWORD}
            - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
            - TZ=${WORKSPACE_TIMEZONE}
          volumes:
            - ${DATA_PATH_HOST}/mysql:/var/lib/mysql
            - ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d
          ports:
            - "${MYSQL_PORT}:3306"
          networks:
            - backend
    

    My Solution:

    PhpStorm->Preferences->Languages & Frameworks->PHP->Test Frameworks

    Add PHPUnit by Remote Interpreter

    Select Docker interpreter

    After created you should add link ( Links section ) which one do u want to use ( mysql, redis) to docker container (click Browse in docker container section)

    And if you know which network is using in docker container you should write name of network ( docker network ls ) into Network Mode section then click OK . That’s it.

    But if you don’t know which network is using . First you should remove all unused networks ( docker network prune ) then run ( docker network ls )

    Hi 👋 this issue has been automatically marked as stale📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

    Hi again 👋 we would like to inform you that this issue has been automatically closed🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

    My Solution:

    PhpStorm->Preferences->Languages & Frameworks->PHP->Test Frameworks

    Add PHPUnit by Remote Interpreter

    Select Docker interpreter

    After created you should add link ( Links section ) which one do u want to use ( mysql, redis) to docker container (click Browse in docker container section)

    And if you know which network is using in docker container you should write name of network ( docker network ls ) into Network Mode section then click OK . That’s it.

    But if you don’t know which network is using . First you should remove all unused networks ( docker network prune ) then run ( docker network ls )

    changing Network mode from bridge to docker internal network fixed my problem

    In my case error was misleading. You have to run commands from docker container eg docker-compose exec containerName (app) php (serviceName) bin/console doctrine:migrations:migrate (service command).
    I was trying to run it from outside of the container. Dunno how not connected redis to doctrine is related during doctrine command, but that was the case. Lost 2-3 hours on that and asked for help other dev.