Hi, I’ve decided to give the roots stack a try for the first time. All was going well until I ran into this error. I’m not sure were the problem would be as I have this project running with trellis, bedrock as well as sage.
For some strange reason when i run gulp and gulp watch the browsersync kicks in, but the url redirects to my staging url instead of my development url (ie. goes to staging.DOMAIN-NAME.com instead of DOMAIN-NAME.dev/localhost:3000). Why would this happen?
I have not set up or provisioned the production settings as yet. I’ve been just testing depolys and building via dev and staging first.
these are the settings that I have in their respective files:
trellis > group_vars > staging > wordpress_sites.yml:
- canonical: staging.kerryreddiar.com
trellis > group_vars >development > wordpress_sites.yml:
- canonical: kerryreddiar.dev
trellis > hosts > staging:
DO droplet IP
DO droplet IP
trellis > hosts > development:
And in my sage theme:
Do date I cannot figure out where I’m going wrong and why my development environment url (kerryreddiar.dev or localhost:3000) keeps redirecting to the staging url (staging.kerryreddiar.com).
Any guidance here would be appreciated. Thanks in advance.
Did you copy your database down from Staging and import it to local at any point? If so, you’ll want to do
wp search-replace [staging url] [dev url]
Thanks for the reply. Yes I did do a db sync using the wp-sync-db plugin prior to a test deploy to staging. I will give this a try, thanks
OK, I ran that command in the site directory and got this error:
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/shaunreddiar/dev/kerryreddiar.dev/site/web/wp/wp-includes/wp-db.php on line 1538
Trying to figure out what I’m doing wrong.
The strange thing is that if I try access the backend on my development environment via DEVURL/wp-admin, i can log in correctly. It seems to be affecting the url only on the front-end. After logging in, I checked my general settings and the urls are correct as shown below:
Another odd thing is that when gulp watch is running, it only goes to the correct development environment if i use the external IP address:
Not sure what went wrong here. This seems to have happened after I test ran a deploy by running ansible-playbook deploy.yml -e “site=mysite.com env=staging” from my trellis directory.
Trying not to have to re-build the project as understanding how this all works will help a lot more
@MWDelaney to answer your initial question, I actually did the opposite, I pushed my DB from development to staging just after I ran the staging deploy. Not sure if that could have caused this.
The search-replace command should be run from the vagrant box; change to your Trellis directory and type
vagrant ssh then
cd /srv/path-to-your-site/current and do the search-replace from there.
I’m not sure what else to check. Everything seems to be set correctly from your reports.
Hey @MWDelaney it worked
After vagrant ssh’ing and doing that search and replace as you suggested, I ran vagrant reload, cleared my browser cache and it seems to be working now.