-1

When launching my web app I get a 500 error. The prod.log shows a connection error to the database, and just below that there is a cache.WARNING: Failed to save key in the /var/www/project/var/cache folder. (Not sure if they are related.)

The error says getaddrinfo failed: Temporary failure in name resolution at /var/www/etc.

I've tried changing the configuration of the db connection string from localhost to 127.0.0.1 to the actual IP address and not seeing a difference.

doctrine:
    dbal:
        # configure these for your database server
        driver: 'pdo_mysql'
        server_version: '5.7'
        charset: utf8mb4
        default_table_options:
            charset: utf8mb4
            collate: utf8mb4_unicode_ci

        url: '%env(resolve:DATABASE_URL)%'

.env DATABASE_URL=mysql://username:password@127.0.0.1:3306/atlas

I'm expecting the configuration to correctly identify the localhost or local ip address and connect to the db.

  • please post result of `php bin/console cache:clear --env=prod` – Manzolo Aug 20 '19 at 20:58
  • Seems like it cant find local IP? Have you tried seeing what the error is about? Temporary failure in name resolution at /var/www/etc – jminkler Aug 20 '19 at 21:00
  • @AndreaManzi I have to use sudo php bin/console cache:clear - not sure if that tells you anything. But it clears it ok. – Brian Barrick Aug 20 '19 at 23:01
  • bbarrick@GRAYFOX /var/www/atlas sudo php bin/console cache:clear [sudo] password for bbarrick: // Clearing the cache for the prod environment with debug false [OK] Cache for the "prod" environment (debug=false) was successfully cleared. – Brian Barrick Aug 20 '19 at 23:02
  • I've changed owner and group to www-data and given it full permissions. Still nothing. – Brian Barrick Aug 20 '19 at 23:55
  • Just realized that changing owner/group back to what I had them originally got rid of the two write permission errors. So far all I have left is the db connection issue. – Brian Barrick Aug 21 '19 at 00:04
  • Still "getaddrinfo failed: Temporary failure in name resolution at /var/www/etc" error with host 127.0.0.1? – Manzolo Aug 21 '19 at 08:50
  • @AndreaManzi yea, that was such a weird error that I suspected something odd was causing it. What I did was renamed the repo, created a new folder and git repo, did a pull. Went through all the steps, composer, gave full read/write permissions to the projects var folder. The db error is now gone, although I'm not getting a page when I log in it is seeing the db. – Brian Barrick Aug 21 '19 at 11:44
  • What error do you receive now, 404? – Manzolo Aug 21 '19 at 11:52
  • @AndreaManzi I fixed it. This was a repo that I had pushed to production and ran in dev mode. Then switched to prod. There wasn't any obvious reason for the db error so I renamed that repo and created a new one. Updated packages and all that - no db error. I'm just going to assume something hung around after changing from dev to prod. Thank you for your help. – Brian Barrick Aug 21 '19 at 14:39

1 Answers1

-1

The issue with db error was resolved by created a new repo for the web app and set to run using prod environment variables from the beginning. I can only assume the old files held on to some configuration somewhere that was causing the issue. With the failure to save key error I resolved that by giving read/write permissions to the projects var folder. The Syfmony docs only suggest doing this to the var/log directory however it had problems writing to other var/ directories as well.