Question

How to link my DB and my Laravel project 500 Error

Posted July 27, 2021 86 views
APIDatabasesLaravel

Hello everybody

i have issue with my Laravel project .

now i have deploy every thing to online

the issue is when i am trying to get my API its giving me 500 Error
and when i checked the log i got the below logs

[db] [2021-07-27 13:32:43] postgresql-12.service [14-1] pid=7152,user=[unknown],db=[unknown],app=[unknown],client=[local] LOG connection received: host=[local]
[db] [2021-07-27 13:32:43] postgresql-12.service [15-1] pid=7152,user=postgres,db=db,app=[unknown],client=[local] LOG connection authorized: user=postgres database=db applicationname=do-pruned
[db] [2021-07-27 13:32:43] postgresql-12.service [16-1] pid=7152,user=postgres,db=db,app=do-pruned,client=[local] LOG disconnection: session time: 0:00:00.007 user=postgres database=db host=[local]
[db] [2021-07-27 13:32:43] postgresql-12.service [14-1] pid=7153,user=[unknown],db=[unknown],app=[unknown],client=[local] LOG connection received: host=[local]
[db] [2021-07-27 13:32:43] postgresql-12.service [15-1] pid=7153,user=postgres,db=defaultdb,app=[unknown],client=[local] LOG connection authorized: user=postgres database=defaultdb application
name=do-pruned
[db] [2021-07-27 13:32:43] postgresql-12.service [16-1] pid=7153,user=postgres,db=defaultdb,app=do-pruned,client=[local] LOG disconnection: session time: 0:00:00.010 user=postgres database=defaultdb host=[local]
[db] [2021-07-27 13:32:53] postgresql-12.service [14-1] pid=7165,user=[unknown],db=[unknown],app=[unknown],client=[local] LOG connection received: host=[local]
[db] [2021-07-27 13:32:53] postgresql-12.service [15-1] pid=7165,user=postgres,db=db,app=[unknown],client=[local] LOG connection authorized: user=postgres database=db applicationname=do-pruned
[db] [2021-07-27 13:32:53] postgresql-12.service [16-1] pid=7165,user=postgres,db=db,app=do-pruned,client=[local] LOG disconnection: session time: 0:00:00.010 user=postgres database=db host=[local]
[db] [2021-07-27 13:32:53] postgresql-12.service [14-1] pid=7166,user=[unknown],db=[unknown],app=[unknown],client=[local] LOG connection received: host=[local]
[db] [2021-07-27 13:32:53] postgresql-12.service [15-1] pid=7166,user=postgres,db=defaultdb,app=[unknown],client=[local] LOG connection authorized: user=postgres database=defaultdb application
name=do-pruned
[db] [2021-07-27 13:32:53] postgresql-12.service [16-1] pid=7166,user=postgres,db=defaultdb,app=do-pruned,client=[local] LOG disconnection: session time: 0:00:00.011 user=postgres database=defaultdb host=[local]

so what is the issue exactly i need to know as i can see its between the DB
but i don’t know the solution

Regards

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello,

It looks like that you need to make sure that you’ve specified the correct database credentials in your .env file.

If you are using a Droplet, you can follow the steps on how to do that here:

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-laravel-application-with-nginx-on-ubuntu-16-04

In case that you are using the App platform you could take a look at this answer here that shows how you could add your database details as env variables:

https://www.digitalocean.com/community/questions/how-to-connect-laravel-project-in-app-platform-to-database-managed-cluster

Let me know how it goes!
Regards,
Bobby

by Mateusz Papiernik
Laravel is one of the most popular open-source web application frameworks written in PHP. It aims to help developers build both simple and complex applications by making frequently-used application tasks (like caching and authentication) easier. In this tutorial, we will deploy a simple Laravel application with a production environment in mind.