How to open via internal IP?

Dear experts,

I really appreciate your contributions!!

Currently I have successfully built the Discourse on local computer and I can open it by localhost:3000. It is so great including creating the topic, post something, etc.

Mainly I was following from here. It is really awesome!

However, I cannot open by my internal IP (i.e., local area network IP). For example, 10.1.2.139. (something like this kind of IP) I wanna open this forum on different devices. (i.e., access it on my laptop.)

Reproduce

Get the bash (install_discourse.sh) script from : https://github.com/techAPJ/install-rails/blob/master/linux

chmod +x install_discourse.sh
sudo ./install_discourse.sh

git clone https://github.com/discourse/discourse.git ~/discourse
sudo -u postgres createuser -s "$USER"
cd ~/discourse

source ~/.bashrc
bundle install

bundle exec rake db:create 
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate

bundle exec rake autospec (something it will have errors.)

Start the server:

bundle exec rails server
or
bundle exec rails server --binding=0.0.0.0

Create a Admin

RAILS_ENV=development bundle exec rake admin:create

Configure Mail

mailcatcher --http-ip 0.0.0.0

Is there any suggestion to access via the local IP?
Thank you so much.

BR,
Chieh

2 Likes

Which command did you use to start the server? You need to use this one:

bundle exec rails server --binding=0.0.0.0
3 Likes

I too have had trouble getting my development box to listen to the ip address with a recent development install on Ubuntu.

I’m pretty sure that I did what Simon recommended as well as using bin/rails

2 Likes

Dear @simonk,

Thanks for your reply!!
I have using ctrl+c to stop the process on terminal, and start by bundle exec rails server --binding=0.0.0.0 this command, but it seems still not work.

I wonder how to correctly stop it then launch again? Because I found even I already closed the terminal that I am still able to access the forum. Moreover, I was not building via docker container so that I have no launcher to use ./launcher stop app this command. Also, I have tried this kill $(cat tmp/pids/server.pid) but it replied cat: tmp/pids/server.pid No such file or directory
I will be grateful for any hint you can provide.

Thank you so much!

BR,
Chieh

1 Like

(Disclaimer: I haven’t run rails like this myself - I use the docker-based development environment instead)

Are you sure about this? I have been caught out before because my browser had cached the discourse application and allowed me to browse between topics even though the server process wasn’t running. You might want to test using curl instead:

curl http://localhost:3000

You could also check to see if any ruby processes are running:

ps -ef | grep ruby

The netstat tool can tell you which processes are listening on which ports. For example, if I run a trivial python web server like this:

$ python3 -m http.server 8099
Serving HTTP on 0.0.0.0 port 8099 (http://0.0.0.0:8099/) ...

Then run netstat:

$ netstat -tlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address    Foreign Address   State    PID/Program name
tcp        0      0 0.0.0.0:8099     0.0.0.0:*         LISTEN   2511478/python3
...

That tells me PID 2511478 is listening on port 8099 on all interfaces (0.0.0.0 means “all interfaces”). To get a bit more information about that process:

$ ps -fp 2511478
UID          PID    PPID  C STIME TTY          TIME CMD
simon    2511478 1250783  0 09:53 pts/11   00:00:00 python3 -m http.server 8099
3 Likes

Hi @simonk ,

Thanks for your information! It is quite useful. In addition, I already moved to docker-container this way.
I will try more on discourse. I am really excited about it.

Thanks again!

BR,
Chieh

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.