Skip to content
Advertisement

Symfony 5 Fast Track: Database access error

I’m trying to go through the aforementioned tutorial, but I get stuck on the stage between Step 7 and 9 – when the database goes into action. On local server I get

An exception occurred in driver: SQLSTATE[08006] [7] fe_sendauth: no password supplied

and while on my deployment server everything seems to work good when reading the database: https://akodg6sfgq-gijxpyj6oxpig.eu.s5y.io/admin/ and entering the conference, when I enter a comment https://akodg6sfgq-gijxpyj6oxpig.eu.s5y.io/admin?crudAction=new&crudControllerFqcn=App%5CController%5CAdmin%5CCommentCrudController&menuIndex=2&referrer=https%3A%2F%2Fakodg6sfgq-gijxpyj6oxpig.eu.s5y.io%2Fadmin%3FcrudAction%3Dindex%26crudControllerFqcn%3DApp%255CController%255CAdmin%255CCommentCrudController%26menuIndex%3D2%26signature%3DGrbeBTskRKkJuU_MbS0do5B1M2XowgfTuOLaqpPQl4M%26submenuIndex%3D-1&signature=Rre3TFXH2NDeRLj9W-LKo6RJXR1fbvm37Cu8H04gfQM&submenuIndex=-1it hits me with

Oops! An Error Occurred
The server returned a "500 Internal Server Error".
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

I don’t know if these two are parts of the same problem, but it coincides.

My .env configuration:

# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
#  * .env                contains default values for the environment variables needed by the app
#  * .env.local          uncommitted file with local overrides
#  * .env.$APP_ENV       committed environment-specific defaults
#  * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=c3aa1e6b44cb8d1cf26c5137433ed753
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
DATABASE_URL="postgresql://127.0.0.1:5432/db?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

.symfony.cloud.yaml:

name: app

type: php:8.0

runtime:
    extensions:
        - apcu
        - mbstring
        - sodium
        - ctype
        - iconv
        - pdo_pgsql
        

#variables:
#    php:
#        # uncomment on PHP 7.4+
#        #opcache.preload: /app/config/preload.php

build:
    flavor: none

disk: 512

web:
    locations:
        "/":
            root: "public"
            expires: 1h
            passthru: "/index.php"



mounts:
    "/var": { source: local, source_path: var }

hooks:
    build: |
        set -x -e

        curl -fs https://get.symfony.com/cloud/configurator | (>&2 bash)
        
        (>&2 symfony-build)

    deploy: |
        set -x -e

        (>&2 symfony-deploy)

relationships:
    database: "db:postgresql"

services.yaml:

db:
    type: postgresql:13
    disk: 1024
    size: S

Docker-compose ps returns:

       Name                   Command           State            Ports         
--------------------------------------------------------------------------------
guestbook_database_1   docker-entrypoint.sh      Up      0.0.0.0:49153->5432/tcp
                       postgres                          ,:::49153->5432/tcp 

and its configuration is:

version: '3'

services:
    database:
        image: postgres:13-alpine
        environment:
            POSTGRES_USER: main
            POSTGRES_PASSWORD: main
            POSTGRES_DB: main
        ports: [5432]

Any ideas? It started after entering API endpoints in the controllers. Basically any access to database. I don’t want to go further until I resolve this.

Advertisement

Answer

Thank you – the username and password were correct. it appears the database has given me the wrong port info. I’ve run the “symfony run psql” and conninfo and got the proper port

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement