Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to open port 3000 on Ubuntu 12.04, cause I have a web server listening there. I'm a bit out of my confort zone here, and spent many hours trying to solve the problem without success.

Port seems to be open in the firewall :

$> sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
3000/tcp                   ALLOW       Anywhere
3000/tcp                   ALLOW       Anywhere (v6)

The server is listening alright on that port :

$> netstat -an | grep "LISTEN "
tcp        0      0*               LISTEN     

And I can even wget alright the index page :

$> wget localhost:3000
Connecting to localhost (localhost)||:3000... connected.
HTTP request sent, awaiting response... 200 OK

And the received file contains what I expect ("hello world" :).

However, when trying from another computer, or if I wget I get "connection refused", and nmap tells me that the port is not open :

$> nmap -A -T4
Host is up (0.00032s latency).
Not shown: 999 closed ports
22/tcp open  ssh     OpenSSH 5.9p1 Debian 5ubuntu1 (protocol 2.0)
Service Info: OS: Linux

Any idea what I should try next ???


Here's what traceroute gives :

$> traceroute
traceroute to (176.31.x.x), 30 hops max, 60 byte packets
 1 (176.31.x.x)  0.034 ms  0.013 ms  0.010 ms
share|improve this question
Disable ufw, try again. If that doesn't work, there is another firewall/device between the remote computer and your server. – izx Jul 20 '12 at 18:53
I tried already .. didn't solve it :( – sebpiq Jul 20 '12 at 19:07
"there is another firewall/device between the remote computer and your server." : this is very unlikely. I tried the second wget from the server so that it makes a round trip through the network. – sebpiq Jul 20 '12 at 19:15
huh? You can't type wget from serverseb and get it to make a round trip without some fancy iptables routing magic. Please pastebin the output of traceroute from the remote computer. You can ** out the last two octets of the last (server) IP for privacy. – izx Jul 20 '12 at 19:19
edited with a traceroute – sebpiq Jul 20 '12 at 20:22
up vote 8 down vote accepted

If your server is listening on the localhost interface only, you won't be able to access it from a remote computer. This appears to be your primary problem, as only is listed in your netstat output.

You will also need to ensure that "" resolves to the correct IP address for your machine, such that connecting to it will result in communication with the external interface of that machine.

share|improve this answer
I can ssh to the machine using its name, so I guess the name resolution is not the problem here. How can I make so that server would listen from anywhere ? – sebpiq Jul 20 '12 at 20:13
@sebpiq This resolution is program-specific. You need to bind the program's listener to the right interface by name{eth0, or something like that), IP address(, or something like that), or the MAC address. This depends on the program. – hexafraction Jul 20 '12 at 20:24
uugh ... sounds insane :S I'll try to google about that. My server is node.js, so I'll check if there's info about what interface I need to connect to. – sebpiq Jul 20 '12 at 20:34
Yeepee !!! @ObsessiveFOSS and dobey thank you SO MUCH ! My node.js server was actually only listening on localhost. I didn't know it was doing like that, and none of the tutorial mentioned that. – sebpiq Jul 20 '12 at 20:40
@sebpiq No problem. :-) – hexafraction Jul 20 '12 at 20:41

I had this problem recently with a nodejs HTTPS server, and the solution to it was not to use "localhost", "" or even the domain name. It was to use ""

I believe this acts as a wildcard, now allowing for public resolution via the domain name and it also works with "localhost"

Edit: Here's a link to a serverfault page on the topic:

share|improve this answer
Use "" where exactly? – Adaephon Jan 28 '15 at 9:34
@Adaephon Well in my case, I created a Node-based web server. I had to change: }).listen(3000, ''); to }).listen(3000, ''); in my code. – Sami Stark Jan 29 '15 at 15:43
@Adaephon So I'm not sure how much help that was, but wherever you're defining the IP/Hostname, try instead. – Sami Stark Jan 29 '15 at 15:53
can you please visit my post?… – Hatul Jun 20 at 15:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.