I have developed a rest api using golang.I have pushed the repository to Heroku.I have also hosted a Mysql Server on the internet.The Go rest api connects to the Mysql Server and fetches and inserts data.
The application on heroku was working fine yesterday.However this morning I get this error on "heroku logs --tail": Web process failed to bind to $PORT within 60 seconds of launch
Here is the code for main.go:
package main
import (
"os"
"github.com/mingrammer/go-todo-rest-api-example/app"
"github.com/mingrammer/go-todo-rest-api-example/config"
)
func main() {
config := config.GetConfig()
app := &app.App{}
app.Initialize(config)
port, ok := os.LookupEnv("PORT")
if ok == false {
port = "3000"
}
app.Run(":"+port)
}
This is known issue for node.js apps on Heroku.
In rarer cases, your app may be using process.env.PORT, but may still be failing to bind. This can be caused by the app attempting to bind on localhost. Instead, you may need to change this to 0.0.0.0.
Can assume the same might be an issue for go service as well. Check out this article on Heroku support site .