Ahmed
Ahmed

Reputation: 55

Can't connect to localhost:3000 after creating Rails project

I recently installed Ruby and then installed Rails. I used the some tutorial as a guide for installing with the commands:

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs

Then using rbenv:

cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.4.1
rbenv global 2.4.1
ruby -v

It's indicating that ruby is installed properly.

I installed bundler:

gem install bundler

Configured Git:

git config --global color.ui true
git config --global user.name "YOUR NAME"
git config --global user.email "[email protected]"
ssh-keygen -t rsa -b 4096 -C "[email protected]"`

I took the newly generated ssh key and pasted it here:

cat ~/.ssh/id_rsa.pub

I installed Rails:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

gem install rails -v 5.1.3

rbenv rehash

then to verify the install:

rails -v

This indicates successful Rails installation.

Then I setup MySQL:

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

Then created a project:

rails new myapp -d mysql

When creating a database:

rake db:create

I get

rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

(See full trace by running task with --trace)

When I run

rails server

and visit localhost:3000 my browser indicates that it is unable to connect.

I installed MySQL with no password.

What is the issue? I previously installed PHP7, MySQL, and phpMyAdmin on the same system. Could this be the problem?

Upvotes: 1

Views: 300

Answers (1)

widjajayd
widjajayd

Reputation: 6263

When running rake db:create, make sure you in your app's folder:

cd myapp
rake db:create

Upvotes: 1

Related Questions