8
votes

I just started to test Google compute engine. Now I'm trying to deploy my Go (golang) application on it, so that it can be reached from outside. I use compute engine in favor of the app engine, since my application requires a MongoDB database.

I did the following:

  1. create compute engine instance
  2. setup up firewall so that port 1234 is open and IP is static
  3. install MongoDB
  4. upload my application
  5. start

The application starts just fine. But I cannot reach it from outside if I open it in my browser with ip:1234. I also tried to start it on port 80 as root user, but this didn't work neither.

The server is configured as following:

{
    "host": "localhost:1234",
    "dbhost": "localhost",
    "db": "dbname",
    "logfile": "log"
}

When I'm using an apache server it servers port 80 and the page is displayed... OS is ubuntu 14.04.

The main simply adds some handlers to a mux and adds a FileServer to the public dir:

mux.Handle("/", http.FileServer(http.Dir(public_dir)))
// [...]
if err := http.ListenAndServe(cfg.Host, mux); err != nil {
    panic(err)
}

So what's the issue here?

1

1 Answers

6
votes

Try changing host from localhost to 0.0.0.0, because right now it's only listening to "inside" requests.