Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 127.0.0.1:3000          0.0.0.0:*               LISTEN     
...

And I can even wget alright the index page :

$> wget localhost:3000
Connecting to localhost (localhost)|127.0.0.1|: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 mydomain.com:3000 I get "connection refused", and nmap tells me that the port is not open :

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

Any idea what I should try next ???

EDIT

Here's what traceroute gives :

$> traceroute mydomain.com
traceroute to mydomain.com (176.31.x.x), 30 hops max, 60 byte packets
 1  mydomain.com (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 serverseb.com from serverseb and get it to make a round trip without some fancy iptables routing magic. Please pastebin the output of traceroute mydomain.com 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
add comment

1 Answer

up vote 4 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 127.0.0.1:3000 is listed in your netstat output.

You will also need to ensure that "mydomain.com" 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
1  
@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(192.168.1.99, 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
add comment

Your Answer

 
discard

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.