How to connect with host PostgreSQL from vagrant virtualbox machine

后端 未结 2 1542
粉色の甜心
粉色の甜心 2020-12-04 14:09

I have a VirtualBox machine running Ubuntu 12.04 in a Mac OS X host machine. In my host machine (Mac OS X), I have PostgreSQL installed. I would like to connect to this Post

2条回答
  •  鱼传尺愫
    2020-12-04 14:56

    You can reach your host from your guest by using the default gateway on your VM.

    See this answer for an explanation.

    By running netstat -rn you can get the default gateway and then use that ip address in your config file of your application.

    Running netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10 should give you the correct ip address. (only tested this on my machine)

提交回复
热议问题