-2

I have a ruby webapp running on the port 5555 on FreeBsd 11. For some reason it's not visible from the Internet at all, although ipfw isn't running.

$ curl -i 12.34.55.66:5555
curl: (7) Failed to connect to 12.34.55.66:5555 port 5555: Connection refused

But the app is visible from that server, from localhost:

curl -i 0.0.0.0:5555
[....returns data]

curl -i 127.0.0.1:5555
[....returns data]

What can be the reason?

update:

$ sockstat
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
user123  ruby       93839 7  tcp6   ::1:5555              *:*
user123  ruby       93839 8  tcp4   127.0.0.1:5555        *:*
Joichi
  • 1
  • 1
  • can you add the output of ``netstat -tlpn|grep 5555``? – allo Oct 10 '17 at 13:28
  • Does your server have a public ip assigned on the network interface or it has a private ip? please provide the output of the command provided by allo – Bogdan Stoica Oct 10 '17 at 13:31
  • @allo netstat: illegal option -- t – Joichi Oct 10 '17 at 13:32
  • @BogdanStoica yes – Joichi Oct 10 '17 at 13:41
  • do you have any firewall running on the server?! – Bogdan Stoica Oct 10 '17 at 13:42
  • Are you running `curl -i 12.34.55.66:5555` from the local machine itself (won't work) or from an external machine? Also, as @BogdanStoica notes, is your machine NAT'd? Do you have a public or private IP? –  Oct 10 '17 at 14:28
  • @Joichi ok, seem to be a gnu option then. Anyway, look to which ip the server binds, you can connect to 0.0.0.0:5555 on the local machine even when its bound to 127.0.0.1. And typical dev-servers bind to localhost by default. – allo Oct 10 '17 at 14:54

1 Answers1

1

I'm not entirely sure whether this applies here, but some ruby webservers like e.g. webrick (the default webserver for Rails) do not bind to your external IP by default. So this might not even be a problem with your firewall, but just a missing configuration. Given the output of sockstat, this might be the case here. For webrick, you should pass -b x.x.x.x to the command to bind the server to your external IP address.

Jaap Haagmans
  • 414
  • 1
  • 3
  • 11
  • where did I say Rails? – Joichi Oct 10 '17 at 14:03
  • That was an example. Your application is not binding to your external IP, that's your problem. Since you did not write which webapp you are using you have to find out yourself on how to configure it properly. – duenni Oct 10 '17 at 14:07
  • @duenni and you don't need to know what app it is. – Joichi Oct 11 '17 at 03:17
  • You didn't say Rails. I took `webrick` as an example as that is a very common webserver in ruby development environments (since it's the Rails default). I'm assuming that you're approaching this machine from another system and that the IP is publicly available. But since you give as little information as you're currently doing, we're all guessing here. – Jaap Haagmans Oct 16 '17 at 15:34