Error when starting server locally: "could not find expected ':'" , Ruby on Rails
<p>I was trying to set up my app on heroku. Before that, I could type <code>rails s</code> to start the server and everything went flawless. </p>

<p>Then (maybe unrelated to my actual problem), I added <code>config.secret_key_base = ENV["SECRET_KEY_BASE"]</code> to my <code>config/evironments/production.rb</code> file and pushed it to github and after that, to heroku. The app on heroku works.</p>

<p>After that, whenever I type rails s, this happens:</p>

<pre><code>mycomp:~/workspace/philosophica$ rails s
=&gt; Booting WEBrick
=&gt; Rails 4.2.5 application starting in development on http://localhost:3000
=&gt; Run `rails server -h` for more startup options
=&gt; Ctrl-C to shutdown server
Exiting
/home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/application/configuration.rb:115:in `rescue in database_configuration': YAML syntax error occurred while parsing /home/sandro/workspace/philosophica/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (&lt;unknown&gt;): could not find expected ':' while scanning a simple key at line 24 column 1 (RuntimeError)
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/application/configuration.rb:98:in `database_configuration'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activerecord-4.2.5/lib/active_record/railtie.rb:117:in `block (2 levels) in &lt;class:Railtie&gt;'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:27:in `each'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activerecord-4.2.5/lib/active_record/railtie.rb:116:in `block in &lt;class:Railtie&gt;'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
        from /home/sandro/workspace/philosophica/config/environment.rb:5:in `&lt;top (required)&gt;'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
        from /home/sandro/workspace/philosophica/config.ru:3:in `block in &lt;main&gt;'
        from /home/sandro/.gem/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
        from /home/sandro/.gem/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
        from /home/sandro/workspace/philosophica/config.ru:in `new'
        from /home/sandro/workspace/philosophica/config.ru:in `&lt;main&gt;'
        from /home/sandro/.gem/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
        from /home/sandro/.gem/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
        from /home/sandro/.gem/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
        from /home/sandro/.gem/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
        from /home/sandro/.gem/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in `app'
        from /home/sandro/.gem/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in `log_to_stdout'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `&lt;top (required)&gt;'
        from /home/sandro/workspace/philosophica/bin/rails:9:in `require'
        from /home/sandro/workspace/philosophica/bin/rails:9:in `&lt;top (required)&gt;'
        from /home/sandro/.gem/ruby/2.2.0/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in `load'
        from /home/sandro/.gem/ruby/2.2.0/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in `call'
        from /home/sandro/.gem/ruby/2.2.0/gems/spring-1.7.1/lib/spring/client/command.rb:7:in `call'
        from /home/sandro/.gem/ruby/2.2.0/gems/spring-1.7.1/lib/spring/client.rb:30:in `run'
        from /home/sandro/.gem/ruby/2.2.0/gems/spring-1.7.1/bin/spring:49:in `&lt;top (required)&gt;'
        from /home/sandro/.gem/ruby/2.2.0/gems/spring-1.7.1/lib/spring/binstub.rb:11:in `load'
        from /home/sandro/.gem/ruby/2.2.0/gems/spring-1.7.1/lib/spring/binstub.rb:11:in `&lt;top (required)&gt;'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/sandro/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/sandro/workspace/philosophica/bin/spring:13:in `&lt;top (required)&gt;'
        from bin/rails:3:in `load'
        from bin/rails:3:in `&lt;main&gt;'
</code></pre>

<p>I noticed this:</p>

<pre><code>YAML syntax error occurred while parsing /home/sandro/workspace/philosophica/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (&lt;unknown&gt;): could not find expected ':' while scanning a simple key at line 24 column 1 (RuntimeError)
</code></pre>

<p>Here is how my database.yml looks like:</p>

<pre><code>default: &amp;default
  adapter: postgresql
  encoding: unicode
  pool: a_number
  host: localhost    #line 21
  username: name     #line 22
  password: password #line 23
                     #line 24
</code></pre>

<p>It mentions an error at line 24, but line 24 is empty. At this point, I'm clueless. Has anyone any advises? Thanks in advance!</p>

<p>Edit 1: My default seems to come first, here my database.yml:</p>

<pre><code>default: &amp;default
  adapter: postgresql
  encoding: unicode
  pool: 5
  host: localhost
  username: name
  password: pasword



development:
  &lt;&lt;: *default
  database: philosophica_development
</code></pre>

<p>Edit 2: When I type in <code>rake routes</code> this happens:</p>

<pre><code>rake aborted!
YAML syntax error occurred while parsing /home/sandro/workspace/philosophica/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (&lt;unknown&gt;): could not find expected ':' while scanning a simple key at line 24 column 1
/home/sandro/workspace/philosophica/config/environment.rb:5:in `&lt;top (required)&gt;'
Psych::SyntaxError: (&lt;unknown&gt;): could not find expected ':' while scanning a simple key at line 24 column 1
(erb):87:in `&lt;main&gt;'
/home/sandro/workspace/philosophica/config/environment.rb:5:in `&lt;top (required)&gt;'
Tasks: TOP =&gt; routes =&gt; environment
</code></pre>

<p>My <code>config/environment.rb</code> looks like this:</p>

<pre><code># Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Rails.application.initialize!  #line 5
</code></pre>

<p>Maybe this is helpful</p>

<p>Edit 3: Here is my gemfile:</p>

<pre><code>source 'https://rubygems.org'

ruby File.read('.ruby-version').strip

gem 'devise'
gem 'figaro'
gem 'pg_search'

gem 'bootstrap3-datetimepicker-rails'
gem 'momentjs-rails'
gem 'bootstrap-datepicker-rails'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use postgresql as the database for Active Record
gem 'mailgun-ruby', '~&gt;1.0.2', require: 'mailgun'
gem 'delayed_job_active_record'
gem 'tinymce-rails'
gem 'pg', '~&gt; 0.15'

group :production do
  gem 'rails_12factor'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~&gt; 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '&gt;= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~&gt; 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'acts-as-taggable-on'
gem 'rake', '~&gt; 11.1.2'
gem 'simple_form'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'gon'
gem 'sprockets'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~&gt; 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~&gt; 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~&gt; 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using &lt;%= console %&gt; in views
  gem 'web-console', '~&gt; 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end
</code></pre>

<p>Edit 4: @Rewritten: You mean like this? If so, I still have the same error</p>

<pre><code>development:
  &lt;&lt;: *default
  database: philosophica_development

default: &amp;default
  adapter: postgresql
  encoding: unicode
  pool: 5
  host: localhost
  username: name
  password: password
</code></pre>