is ip address on remote machine the same as localhost on local machine?

July 28, 2014 4.7k views

I have a Go program (see this gist that when I run on my local machine starts a server and handles two routes localhost:8080 and localhost:8080/login

I installed Go on an ubuntu server and am able to run the program, however, when I go to my ip addresss and/or, my browswer appears to be trying to connect and then I get a message that a page isn't available

I assumed that my ip address on the remote server was the same as localhost on my local machine, so if I simply run the Go program on my localmachine and can view it in the browser, shouldn't I be able to do the same on the remote machine?

Is there some other type of configuration I need to set up besides what it says in the tutorial for setting up a Ubuntu server?

1 Answer

localhost =, and is local class meaning it cannot be accessed anywhere but from the machine itself. You need to bind your app to the external ip address to listen for remote requests.

You can test this by typing 'nslookup localhost' on your droplet.

  • Thanks, running nslookup localhost gave me


    My hello world app runs listen and serve on port 8080

    http.ListenAndServe(":8080", nil)

    By binding it to the external ip address, are you saying it should be something like this

    http.ListenAndServe("", nil)

    or is there a tutorial on DO you can refer me to

  • http.ListenAndServe("", nil)

    Yes, that looks correct.

Have another answer? Share your knowledge.