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

onurzdgn's avatar

Laravel Deploy DigitalOcean

Hello everyone. I am using Laravel 11 and trying deploy on Digital Ocean App platform. I was saw 500 error and I open debug mode after I see this error SQLSTATE[HY000] [2002] No such file or directory (Connection: mysql, SQL: select * from `sessions` where `id` = 2A4kJSBXhL0bGzoOnu934evNCvxlgiCehqxoIygF limit 1) When I search logs I saw this

2024-07-24 20:54:06] production.ERROR: SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select * from `sessions` where `id` = W9CC2votLpBG7HFnQnBtO0ogy1UfmH7y6zE3nPBE limit 1) {"exception":"[object] (Illuminate\Database\QueryException(code: 2002): SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select * from `sessions` where `id` = W9CC2votLpBG7HFnQnBtO0ogy1UfmH7y6zE3nPBE limit 1) at /workspace/vendor/laravel/framework/src/Illuminate/Database/Connection.php:813)

I control my db settings 3 times.

0 likes
6 replies
tisuchi's avatar

@onurzdgn Check your database connection credentials. It seems the app is unable to connect with db.

2 likes
onurzdgn's avatar

@tisuchi I will check and I can't see any problem. I have 3 web app and 1 mysql and 3 database. 2 web is working I was open new database and same problem.

onurzdgn's avatar

@tisuchi I think I found real problem:

In Connection.php line 813:


SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select table_name as name, (data_length + index_length) as si
ze, table_comment as comment, engine as engine, table_collation as collation from information_schema.tables where table_sche
ma = 'laravel' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)


In Connector.php line 65:


SQLSTATE[HY000] [2002] Connection refused
tisuchi's avatar

@onurzdgn If you found the solution, that would be great.

SQLSTATE[HY000] [2002] Connection refused

This is a clear indication to me that, It's unable to connect to DB.

1 like
onurzdgn's avatar
onurzdgn
OP
Best Answer
Level 2

@tisuchi I fix it. Other project work with 127.0.0.1 but this is not work. Then I use remote link. I think problem from digital ocean

jlrdw's avatar

To add, digital ocean does have how to articles that might help.

1 like

Please or to participate in this conversation.