我正在运行的迷途盒(ubuntu,在主机上)运行得很好。
我正在尝试从主机上设置pgAdmin,并且在为sql流量打开一个新端口时遇到了问题。
我在我的Vagrantfile中添加了一行(最后一行):
config.vm.network "forwarded_port", guest: 3000, host: 8080 # http
config.vm.network :forwarded_port, guest: 35729, host: 35729
config.vm.network "forwarded_port", guest: 5432, host: 7001 # postgres我运行了流浪汉规定,并弹出了几次Vagrant。当它重新启动时,未列出新的端口转发:
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 3000 => 8080 (adapter 1)
default: 35729 => 35729 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!卷曲也给出了否定的反应:
➜ ~ curl -v 'http://localhost:7001/'
* Adding handle: conn: 0x7fde1a004400
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fde1a004400) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 7001 (#0)
* Trying ::1...
* Trying 127.0.0.1...
* Trying fe80::1...
* Failed connect to localhost:7001; Connection refused
* Closing connection 0
curl: (7) Failed connect to localhost:7001; Connection refused相关员额:
Vagrant Port Forwarding not working
Cannot connect to Postgres running on VM from host machine using MD5 method
发布于 2014-06-28 00:26:27
由于5432<->7001端口映射没有列在Vagrant序列中,所以它没有发生。
我会尝试一个vagrant reload,它应该再次重新加载Vagrantfile文件的这些部分。
如果这不起作用,您还可以尝试手动添加端口映射,至少确认到应用程序的连接。Change Vagrant port forwarding on a running system的公认答案解释了如何在VirtualBox UI中这样做。
发布于 2018-09-15 20:35:56
除了打开VirtualBox设置之外,设置临时终端的另一种方法是使用vagrant ssh,在--之后提供附加参数
vagrant ssh -- -L 3000:localhost:3000这将把主机上的端口3000转发到客户上的端口3000。
第一个号码是给主机的。若要将主机上的端口7001转发到客户上的默认postgresql端口,请执行以下操作:
vagrant ssh -- -L 7001:localhost:5432这只会持续到您的ssh会话。如果ssh断开连接,请再次运行它。要使它在重新启动后保持不变,请将其添加到您的Vagrantfile中。
https://stackoverflow.com/questions/24461014
复制相似问题