I have Ruby 2.1.2 installed and Rails 4.2.

Bundle install runs without error.

I can do a Rails C without error.

Rails s -p3004 launches with webrick or thin without error

When I browse to mytestsite:3004 safari, firefox, and chrome all report "can't connect to server"

No errors show in any system logs; syslog, lfd.log, auth.log, or any of the apache logs.

If I launch my 4.04 site, ports 3001, 3002 work fine. If I bring down 4.04, and launch 4.2 on port 3001 or 3002, I get the 'can not connect to server' error. This seems to mean to me that it's not a firewall issue blocking the port. Nonetheless, iptables -L reports that port 3004 is open:

ACCEPT     tcp  --  anywhere             anywhere             ctstate NEW tcp dpt:3004

Rails reports:

=> Booting WEBrick  
=> Rails 4.2.0.beta1 application starting in development on http://localhost:3004   
=> Run `rails server -h` for more startup options  
=> Ctrl-C to shutdown server  
[2014-09-02 21:31:06] INFO WEBrick 1.3.1  
[2014-09-02 21:31:06] INFO ruby 2.1.1 (2014-02-24) [x86_64-linux]  
[2014-09-02 21:31:06] INFO WEBrick::HTTPServer#start: pid=4599 port=3004  

(same result with thin).

Telnet localhost 3004 works from the server however telnet from another server to the port and ip address results in a connection refused.

and ps reports the program is loaded:

ps aux|grep 3004  
user 1062 0.0 0.5 578600 183996 pts/2 Sl+ 20:15 0:03 /home/user/.rvm/rubies/ruby-    2.1.1/bin/ruby bin/rails s -p3004

which is also confirmed by netstat:

netstat -tpln | grep 3004  
tcp 0 0* LISTEN 1062/ruby  

but mmap reports the port is closed:

Starting Nmap 6.40 ( http://nmap.org ) at 2014-09-02 21:33 UTC  
Nmap scan report for localhost (  
Host is up (0.000059s latency).  
rDNS record for 127.0.x.1: local_host.local_domain  
3004/udp closed unknown  

And a telnet to the server 3004 reports connection refused.

Like I said, I'd think it was a firewall issue except that changing to port 3001, which I know to work with Rails 4.04, fails with 4.2. Anyone have any suggestions?


WEBrick bound to rather than to INADDR_ANY, so you can only access it via that address. If you want to set what address it binds to, use the -b option. For example:

rails s -b -p 3004

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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