You've started well, but for local LAN only.
- For intranet only, you can use your LAN ip.
Test it from another local machine (same LAN). Hope it works.
If your firewall and machine settings allow you to view on intranet, than go to next step:
- For internet,
first make sure you have your public internet address, by visiting
http://api.ipify.org/
> you will see your public IP address. Use it to access your website http://<public_address>:3000/
If it works on intranet, but not on internet, you need to open the port 3000 in your router and forward it to your local machine. (If you have no access to router settings, ask your administrator to help you with this).
Give me more details for a more complete solution.
What OS are you using?
EDIT:
For Windows10 you have to make sure to open the port 3000 in your firewall.
- Navigate to Control Panel, System and Security and Windows Firewall.
- Select Advanced settings and highlight Inbound Rules in the left pane.
- Right click Inbound Rules and select New Rule.
- Add the port you need to open and click Next.
- Add the protocol (TCP or UDP) and the port number into the next window and click Next.
- On the "Profile" step select all 3 (Domain, Private, Public)
- Select Allow the connection in the next window and hit Next.
- Select the network type as you see fit and click Next.
- Name the rule something meaningful (like: Allow incoming connections on port 3000) and click Finish.
To change the default 3000 port use:
rails server -p 8080
to change port
rails server -b 0.0.0.0
to bind 0.0.0.0 address
UPDATE:
When server starts will output to the console, the address:port it listens. example:
Listening on tcp://0.0.0.0:3000
as a development server it can be set to listen on localhost requests only.
To override that settings use:
rails server -p <3030> -b 0.0.0.0
this will listen to all incoming connections on port 3030
For more details on the -p
, and -b
consult the help:
$ rails server -h
Usage: rails server [mongrel, thin etc] [options]
-p, --port=port Runs Rails on the specified port.
Default: 3000
-b, --binding=IP Binds Rails to the specified IP.
Default: localhost
-c, --config=file Uses a custom rackup configuration.
-d, --daemon Runs server as a Daemon.
-e, --environment=name Specifies the environment to run this server under (test/development/production).
Default: development
-P, --pid=pid Specifies the PID file.
Default: tmp/pids/server.pid
-C, --[no-]dev-caching Specifies whether to perform caching in development.
true or false
-h, --help Shows this help message.