通过虚拟机上的localhost:port访问node.js / grunt服务器 [英] Access node.js/grunt server through localhost:port on virtual machine

查看:108
本文介绍了通过虚拟机上的localhost:port访问node.js / grunt服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Grunt在端口9000上本地运行node.js服务器。我也有一台运行(vmware)的虚拟机,但我无法通过它来访问节点服务器。我已经配置虚拟机通过本地主机访问主机上的Apache服务器,但是:9000给出'未找到'。

I'm running a node.js server locally on port 9000 through Grunt. I also have a virtual machine running (vmware), but I can't access the node server through that. I've already configured the VM to access my Apache server on the host through localhost, but :9000 gives 'not found'.

任何人都知道如何做到这一点?

Anyone know how to do this?

推荐答案

明白了!在我的项目的 Grunt.js 文件中有这样的设置:

Got it! In my project's Grunt.js file there was this setting:

grunt.initConfig({
    ...
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
    }
    ...
  });

我只需要更改 localhost 0.0.0.0 并重新启动 grunt server

All I had to do was to change localhost to 0.0.0.0 and restart grunt server.

这篇关于通过虚拟机上的localhost:port访问node.js / grunt服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆