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

staticwave's avatar

Trouble Deploying Laravel 5 on VPS Subdomain

I have been using Laravel for quite a while but only recently have the need to deploy an app on a subdomain and I'm having some trouble. Everything works as it should if it's not deployed under a subdomain.

So I have: domain.com (main site) and subdomain.domain.com (app)

When I pull up the subdomain in the browser the index page loads fine(subdomain.domain.com), but when I try to access the login view(subdomain.domain.com/auth/login) - or any other view other than index - I get the following error:

ErrorException in Connector.php line 47: SQLSTATE[HY000] [2002] No such file or directory (View: /var/www/vhosts/domain.com/subdomain/resources/views/app.blade.php) (View: /var/www/vhosts/domain.com/subdomain/resources/views/app.blade.php)

So, it appears Laravel is looking for resources in the wrong directory, but I don't know where to configure the app to look for them in the correct location.

I have tried wrapping my routes in Route::group(['domain' => 'subdomain.domain.com']....but that didn't help.

Can anyone please point me in the right direction here? Thanks.

0 likes
5 replies
SCC's avatar

Going to need more information about your setup and how you have configured the sub domain. Have you updated the confg/app.php with the correct path, are using vagrant or homestead? Not enough info to know how to help.

Clearly it can't find the directory so you need to trace back, it is a likely a configuration issue.

staticwave's avatar

Thanks. It's on a GoDaddy VPS. Yes, I have update config/app.php url to: http://subdomain.domain.com

I setup the subdomain via Plesk and the root points to the public folder under the subdomain.

SCC's avatar

Ok, the error message says

SQLSTATE[HY000] [2002]

Which indicates a database connection issue

The main page will work fine because it requires no database connections, check that you have that configured correctly in order for it to access subdomain.domain.com/auth/login

Is MySQL running, have you got the config file set to something like 192.168.0.1 instead of localhost?

Check all the settings in .env and config/database.php

staticwave's avatar

I had dismissed the possibility of it being a db issue previously because I knew the credentials were correct and I had deployed in on the top-level for testing and it worked. I just checked my .env file again and everything is correct, but I added port :3306 to localhost and now it's working!

Thanks for getting me to look at the host!

SCC's avatar

Cool, glad you got it working.

Please or to participate in this conversation.