Cannot view 0.0.0.0:3000 in browser, and localhost:4000 gives error

This is my cmd log:

intl@intl-PC  /f/discourse (master)
$ vagrant ssh
VM must be running to open SSH connection. Run `vagrant up`
to start the virtual machine.

intl@intl-PC  /f/discourse (master)
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 3000 (guest) => 4000 (host) (adapter 1)
    default: 1080 (guest) => 4080 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 5.0
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => F:/discourse
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

intl@intl-PC  /f/discourse (master)
$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)

 * Documentation:  https://help.ubuntu.com/
New release '14.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Welcome to your Vagrant-built virtual machine.
Last login: Sun Mar 20 07:47:34 2016 from 10.0.2.2
[vagrant@precise32:/vagrant (master)]$ bundle exec rails s -b 0.0.0.0
You are running an old version of bundler, please upgrade bundler ASAP, if you are using Discourse docker, rebuild your container.
You are running an old version of bundler, please upgrade bundler ASAP, if you are using Discourse docker, rebuild your container.
=> Booting Thin
=> Rails 4.2.6 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop

Whenever I go to 0.0.0.0:3000, it tells me:

So, I tried localhost:4000 (but that’s not the url the cmd says), but this page now gives me a new error:

ExecJS::RuntimeError in List#latest
Showing /vagrant/app/views/layouts/application.html.erb where line #29 raised:

SyntaxError: discourse/models/badge-grouping: Unexpected token (6:2)
  4 | export default RestModel.extend({
  5 | 
> 6 |   @computed('name')
    |   ^
  7 |   i18nNameKey() {
  8 |     return this.get('name').toLowerCase().replace(/\s/g, '_');
  9 |   },
  (in /vagrant/app/assets/javascripts/discourse/models/badge-grouping.js.es6)
Extracted source (around line #45):
              
43      tags.html_safe
44    else
45      javascript_include_tag(*args)
46    end
47  end
48

Rails.root: /vagrant

Application Trace | Framework Trace | Full Trace

app/helpers/application_helper.rb:45:in `script'
app/views/layouts/application.html.erb:29:in `_app_views_layouts_application_html_erb__915713446_127392560'
lib/topic_list_responder.rb:15:in `block (2 levels) in respond_with_list'
lib/topic_list_responder.rb:11:in `respond_with_list'
app/controllers/list_controller.rb:85:in `block (2 levels) in <class:ListController>'
config/initializers/100-quiet_logger.rb:10:in `call_with_quiet_assets'
config/initializers/100-silence_logger.rb:26:in `call'
lib/middleware/missing_avatars.rb:21:in `call'
lib/middleware/turbo_dev.rb:33:in `call'

Request

Parameters:

None
Toggle session dump
Toggle env dump
Response

Headers:

None

(also, when I get this error, my cmd automatically gets filled with hundreds of lines of code of .scss. Strange!)

My path to getting vagrant set up seems to be pre-filled with obstacles which I don’t understand :confused: Please help me with this error. Thanks! :slight_smile:

The correct port is 4000 (it’s 3000 inside vagrant and 4000 outside).

Looks like you got a error on Execjs, maybe because you’re on windows - which is strange because vagrant was supposed to solve this.

The bundle install goes fine?

1 Like

You don’t want to go to 0.0.0.0. That particular IP of a server means “any server”, which means the virtual machine listens to all IPs that belong to a computer (useful as a shortcut meaning if application doesn’t want to specify an IP it listens from), but you cannot access your virtual machine without VirtualBox bridge, which sets localhost port 4000 to redirect to port 3000 of your virtual machine.

You should use localhost:4000 instead of 0.0.0.0:3000

2 Likes

As I have said before, I have already used that:

but same error.

Yes, I have done bundle install and bundle update both.

That may be your problem.

The Discourse Gemfile and Gemfile.lock files have versions for some gems specified.
Despite what vagrant may be telling you, I recommend you don’t manually upgrade any gems and let Discourse handle the versions.

Also, are you starting it up with
bundle exec rails s -b 0.0.0.0

Then, as said point your browser to localhost:4000

Unfortunately, I have already run bundle update :frowning: Vagrant was constantly telling me:

You are running an old version of bundler, please upgrade bundler ASAP…

And things weren’t working properly for me so maybe I thought this is the problem so I ran bundle update. Anyway to revert this to get things working properly?

And yes I am using bundle exec rails s -b 0.0.0.0 and localhost:4000

Unfortunately, if there is a way to “undo” or “rollback” I don’t know how.

I had a few false starts, each time getting a bit further. But what I did was uninstall GitHub, VirtualBox, and Vagrant paying more attention to things I might have missed before and trying things a bit different. (and yes, upgrading gems was one thing I tried)

The first “successful” attempt ran painfully slow. I believe it was because I installed everything directly under C and Windows had a security / privilege problem with that. At least I think that was why I had “sharing” problems.
That, and I was opening the shell from the GitHub GUI

Then I upgraded to Windows 10 and everything broke, forcing me to try again.

This last time, which knock wood has been running well, I:

  • installed GitHub - used all defaults

  • installed VirtualBox - used all defaults

  • installed Vagrant - used all defaults

  • instead of putting my “work” under C I put it under
    C:/users/[me]/documents/virtualworkspace/discourse

  • I open the shell from the Start menu - GitHub - Git Shell

  • I don’t touch the GitHub or VirtualBox GUI

It takes a bit more effort cd’ing to the work folder, but Windows hasn’t complained yet.

1 Like

Thanks! :slight_smile: But I am a bit hesitant to try this fix, especially since it involves everything that I did :frowning: