PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] How to connect to database on NAS from Vagrant-box

 September 21, 2022     database, ip, nas, vagrant, virtualhost     No comments   

Issue

I am currently developing a website with a virtual server based on Vagrant. Before that I always used my NAS-webserver to develop my sites. I want to keep using my database on the NAS cause it's easy to handle through phpMyAdmin that is installed as an app on the NAS.

When ssh'ed into my virtualbox I can ping to the internal ip from my NAS, being 192.168.0.10. Making a database connection to it, does not work.

Usually I take static ip for my VirtualBox that does not belong to the range of my internal network, e.g. 192.168.33.23. I tried to change this to an ip that is in the range but then I get an error saying:

The specified host network collides with a non-hostonly network!
The specified host network collides with a non-hostonly network!
This will cause your specified IP to be inaccessible. Please change 
the IP or name of your host only network so that it no longer matches that of a bridged or non-hostonly network.

What is the best method to solve this issue? I read the Vagrant Docs and other posts but I didn't get it up and running.

** UPDATE **

I added this line to my Vagrantfile:

config.vm.network 'public_network'

This invokes a bridged mode. After choosing 'en0: Wi-Fi (Airport)' as adapter when starting the VM, the ip of my VM is now 192.168.0.100 but I still can't connect to my database @192.168.0.10. I already did a credential check by placing all files on the NAS-webserver and all worked well.


Solution

Solution:

  • set the network to bridged mode
  • grant the VM ip address access in the mysql users table

So I just added the same user in phpMyAdmin but now with the VM ip address as hostname.



Answered By - bflydesign
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing