Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Kris01's avatar

Laravel Deployed Project

Hello guys,

I am working on a project, the app is deployed on digital ocean. I am new to the project, and I can't find where the database is located. When I open the .env file on live, it says DB_HOST = 127.0.0.1

How is it possible that everything works fine even tho the host is set to local? Where should I look for the database?

0 likes
6 replies
OussamaMater's avatar

your database service is running locally, if you check services, you will see that 127.0.0.1 is bound to the port 3306, so the database is only accessible locally, by your application, and that's exactly what you want, you don't want to expose your DB to the internet, you only want it to be accessed by your application.

If you want to check your database, simply run

mysql -u <username> -p

And you will be prompted for that user's password, the ones you're using in the .env file, or if you have not made any changes or low privileged users, you can do

sudo mysql

Hopefully this make the idea clear, else, I am happy to answer your questions.

2 likes
Kris01's avatar

@OussamaMater thanks for the reply. I just have one question, locally where? On the same server where the application is?

OussamaMater's avatar
Level 37

@Kris01 Yes locally in the same server, I made you a simple diagram, to help you understand it better

In the diagrams user's can't access your database because it's running locally, only other services in your server can access it, others can't, while your Laravel application is being exposed by a webserver (like nginx or apache) to the public.

If you have more questions, don't hesitate, if not please close the thread by setting a "best answer", for future comers :)

1 like
Snapey's avatar

@Kris01 commonly with this type of setup, if you want to administer the mysql server remotely, you need to tell your database tool to ssh into the server and then connect to localhost

1 like
Kris01's avatar

@Snapey I had a talk with another developer and he made me question one thing. Is it true that this kind of database setup is less efficient? If I have big amount of data, will this work better or should I setup the db separately?

Snapey's avatar

@Kris01 Its more efficient as the network round trip is non-existent.

The downsides are that you have to scale the database at the same time as your web server, the architecture (eg disks) may not be optimised for database work and it does not work for scaling-out.

It really depends on your requirements. Ultimately you will tend towards separate database infrastructure, but probably not until you have hundreds of requests per second.

The amount of data you have is largely irrelevant unless you are talking about TB+

1 like

Please or to participate in this conversation.