rib3ye
rib3ye

Reputation: 2923

Why can I see my Apache server on port 80, but not my Webrick server on port 3000?

I'm running Apache on port 80 and Rails (Webrick) on port 3000.

Using http://localhost and http://localhost:3000, I can see both servers. However, using my local IP, I can still see the Apache serv, but not the Rails serv.

Running cURL, again, Apache returns 200, but Rails returns curl: (7) Failed to connect to <ip> port 3000: Connection refused

Update
I restarted the server using the -b IP binding option and my IP, but can no longer hit it from localhost:3000. Is there a way to bind to both?

Upvotes: 0

Views: 195

Answers (1)

Philip Hallstrom
Philip Hallstrom

Reputation: 19899

Pass 0.0.0.0 as your argument. That will bind to all interfaces.

If you want to make this permanent you can monkey patch some of Rails by adding the following to config/boot.rb:

require 'rails/commands/server'
module Rails
  class Server
    def default_options
      super.merge(Host: '0.0.0.0', Port: 3000)
    end
  end
end

Just keep in mind that this will make it publicly available if you're on a shared network.

Upvotes: 1

Related Questions