lukmil
lukmil

Reputation: 165

Symfony3 The server returned a "500 Internal Server Error"

I wanted to put my symfony3 code to hosting and after all i got

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.

my parameters.yml

# This file is auto-generated during the composer install

parameters:

database_host: db.if.ktu.lt
database_port: null
database_name: lukmil
database_user: lukmil
database_password: "MyPassword"
mailer_transport: smtp
mailer_host:       127.0.0.1
mailer_user:       ~
mailer_password:   ~
secret: ThisTokenIsNotSoSecretChangeIt

that's what i get from prod log

[2016-10-11 18:18:40] request.INFO: Matched route "{route}". {"route":"authentication_register","route_parameters":{"_controller":"AppBundle\Controller\DefaultController::indexAction","_route":"authentication_register"},"request_uri":"http://lukmil.stud.if.ktu.lt/register","method":"GET"} [] [2016-10-11 18:18:40] security.INFO: Populated the TokenStorage with an anonymous Token. [] [] [2016-10-11 18:18:40] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionException: "An exception occured in driver: SQLSTATE[28000] [1045] Access denied for user 'root'@'stud.if.ktu.lt' (using password: NO)" at /home/lukmil/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 103 {"exception":"[object] (Doctrine\DBAL\Exception\ConnectionException(code: 0): An exception occured in driver: SQLSTATE[28000] [1045] Access denied for user 'root'@'stud.if.ktu.lt' (using password: NO) at /home/lukmil/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:103, Doctrine\DBAL\Driver\PDOException(code: 1045): SQLSTATE[28000] [1045] Access denied for user 'root'@'stud.if.ktu.lt' (using password: NO) at /home/lukmil/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 1045): SQLSTATE[28000] [1045] Access denied for user 'root'@'stud.if.ktu.lt' (using password: NO) at /home/lukmil/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} []

What could I do? On localhost it worked.. just in hosting doesn't

Upvotes: 2

Views: 19290

Answers (5)

user16306919
user16306919

Reputation: 11

$kernel = new AppKernel('prod', true);

in path /web/app.php.

Upvotes: 1

juanitourquiza
juanitourquiza

Reputation: 2194

Is important check the twice enviroments. For example in my case my code is perfect in dev: app_dev.php/web/login

but in production: /web/login

I have this error: “500 Internal Server Error”

Then I checked the log of production and finded the error.

Maybe is help you too.

Regards

Upvotes: 0

manuerumx
manuerumx

Reputation: 1250

You are using root without a password. Please don't.

Check this Access denied for user 'root@localhost' (using password:NO)

And create a user to access the database, try not to use the root user.

Remove the " from the password

The parameters should be like this:

database_port: null
database_name: lukmil
database_user: lukmil
database_password: MyPassword

Upvotes: 0

lukmil
lukmil

Reputation: 165

Ok, I found a fix.. I downloaded putty program then logged in and use php bin/console cache:clear --env=prod with clearing the cache my problem solved :)

Upvotes: 12

Ryan
Ryan

Reputation: 1191

Make sure your database credentials for your server are correctly added to your configuration file (.yml) and that your database user has the permissions to access the database your attempting to access.

Good practice would be to create a user with access to the respective database only as using root shouldn't be used directly.

Upvotes: 0

Related Questions