Report this

What is the reason for this report?

getting database connection error if connect the site without www

Posted on July 27, 2014

Hey,

I’m running Wordpress latest package on Ubuntu 14.04 with apache and mysql server. Everyting was running perfectly, but this evening I’m getting database connection error without using www.

Here is sites: http://filmloverss.com/ (Failing) http://www.filmloverss.com/ (Running perfectly)

I’m also using monit for keep running whole system. So the monit status is returning everyting is perfect.

So what ist the problem? How can I solve this?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Here is what I got from both sites:

http://filmloverss.com/

<!-- Dynamic page generated in 43.190 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2014-07-28 01:43:15 -->

<!-- super cache -->

http://www.filmloverss.com/

<!-- Dynamic page generated in 0.602 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2014-07-28 06:10:50 -->

<!-- super cache -->

WP super cache maybe the cause. Seems like it have different caches for non-www and www version.

If you don’t want to deal with it right now, just add a rewrite rule to redirect non-www to www

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Ref: http://stackoverflow.com/questions/2015159/htaccess-redirect-for-non-www-both-http-and-https

Thank you so much! I removed the Wp Super Cache plugin with all setting files. Then re-enabled. So, it worked!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.