Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status code 500 with no database connection #3715

Closed
wp-coin opened this issue May 6, 2024 · 12 comments
Closed

status code 500 with no database connection #3715

wp-coin opened this issue May 6, 2024 · 12 comments

Comments

@wp-coin
Copy link

wp-coin commented May 6, 2024

docker 24.0.0 ( downgraded)
ubuntu 22 wsl2

Lando v3.21.0-beta.18

I am getting an error (Request failed with status code 500)

@wp-coin wp-coin added the bug Something aint working right! label May 6, 2024
@AaronFeledy
Copy link
Collaborator

This error is likely not related to Docker. Have you tried running lando rebuild? In order to help, we need more information about your setup, what you're trying to accomplish, what steps lead to the error, what troubleshooting steps you have tried, etc.

@AaronFeledy AaronFeledy removed the bug Something aint working right! label May 6, 2024
@wp-coin
Copy link
Author

wp-coin commented May 6, 2024

This error is likely not related to Docker. Have you tried running lando rebuild? In order to help, we need more information about your setup, what you're trying to accomplish, what steps lead to the error, what troubleshooting steps you have tried, etc.

steps I tried so far:
lando rebuild
lando restart

scan of 'http://localhost:32771/' failed with 500 'Internal Server Error' +9ms
scan of 'https://localhost:32770/' failed with 500 'Internal Server Error' +3ms

@wp-coin
Copy link
Author

wp-coin commented May 7, 2024

so basically after updating the database connection I am getting 302
https://localhost:32776 [302]
http://localhost:32777 [302]

and then after restarting I am getting 301 on the localhost and 200 on http://lando.site/

I think I should still get 200 even if the database is not connected properly so I can get the error message from WordPress

@wp-coin wp-coin changed the title Docker Engine status code 500 with no database connection May 7, 2024
@AaronFeledy
Copy link
Collaborator

I think that's just how wordpress works. If the database isn't connected, it 301 redirects you to setup. If the lndo.site domain is working but localhost is not, it's likely that your Wordpress is configured in a way that 302 redirects you away from the localhost domain. If that's the case, these aren't errors, but Wordpress trying to direct you to the correct urls.

@wp-coin
Copy link
Author

wp-coin commented May 9, 2024

it does not work that way, it only redirects to the install page if there is no database setup or ( empty fields), if the fields are filled in and wrong it's supposed to give you a message on screen “Error Establishing a Database Connection”

the status code should be 200 with or without database connection ( not 500 ) which is at the server level and I'm guessing it has something to do with proxy server you setup in traefik

@joshuami
Copy link

joshuami commented May 9, 2024

It may be related that after running lando update, I'm no longer getting an ARM compatible database image. For me at least, that seems to be the cause of the 500 errors.

@joshuami
Copy link

joshuami commented May 9, 2024

Sorry, that likely has nothing to do with your issue seeing that you are on WSL. My bad. I didn't read carefully enough. 😉

@reynoldsalec
Copy link
Sponsor Member

@wp-coin the 300's are likely an initial response code that redirects to a 200; the Lando scanner doesn't follow redirects, so 300's would be expected. See the scanner docs for more details and options to configure: https://docs.lando.dev/core/v3/scanner.html

Is your database is connecting correctly now?

@wp-coin
Copy link
Author

wp-coin commented May 9, 2024

yes my database is connected, I am getting 301 on localhost and 200 on lando.site, that's because my WP settings is setup to use lando.site address

WP should work like any other php application, don't need to check if the DB is connected or not, just make sure nginx or Apache shows valid 2xx, 3xx, or 404 response code

this scanner might be working differently than what I imagined, its scanning the app not the server, but it should really be scanning the server for status code and give me control of the app.

you should probably be using this to check status information for nginx, https://nginx.org/en/docs/http/ngx_http_status_module.html

https://nightlies.apache.org/httpd/trunk/doxygen/group__HTTP__Status.html

@AaronFeledy
Copy link
Collaborator

AaronFeledy commented May 9, 2024

Lando indeed checks the status of the individual services. Only after it confirms that they're up does it start the scanner. The purpose of the scanner is to get a status from your application to see if it's functioning in the Lando environment. A good indication of a responsive application is when that application is able to return a 200 or 3xx response to a request. A 4xx could even be considered a success in some scenarios, which is why the scanner is configurable.

@wp-coin
Copy link
Author

wp-coin commented May 9, 2024

It appears that Lando may be overinvolved in the app's functionality, leading to unnecessary complications. I recommend reviewing this to potentially reduce the challenges.

you are probably thinking of a NodeJS app which does not require Apache or nginx, but for best practice and for best performance, though, you'll combine node.js with nginx, depending on the needs of your application. nginx does a better job of serving static files, though at the highest performance for static files will come from using a CDN. Most often, you'll use nginx as a reverse proxy: the web request will be received by nginx, which acts as a load balancer in front of several identical or subdivided servers. If it needs to server static files as well, it will just answer those requests directly.

@AaronFeledy
Copy link
Collaborator

Lando leaves it entirely up to you to make your application work the way you like. If your app's code checks the domain name and issues a redirect based on that then Lando will stay out of the way.

It seems you were able to get your database connected and we've verified that Lando is not preventing your application from issuing its desired redirects so I'm going to close this issue. Feel free to open another issue or ask for support in the Slack Channel if you need anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants