Fix 500 Error: Creating Test Env In Docker
Hey guys,
I was just diving into testing and setting up my first environment when I ran into a nasty 500 Internal Server Error. This happened right after I created a network, and now I'm getting the same error when I try to view my host. Super frustrating, right? Let's break down what's going on and see if we can figure out a fix.
Here’s a snapshot of what I'm seeing:
And here are the logs that might give us some clues:
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] Started GET "/exercises/testenv/virtual_machines/1" for 10.36.246.254 at 2025-08-14 09:13:11 +0000
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] Processing by VirtualMachinesController#show as HTML
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] Parameters: {"exercise_id" => "testenv", "id" => "1"}
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] Rendered layout layouts/application.html.haml (Duration: 165.0ms | GC: 12.3ms)
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] Completed 500 Internal Server Error in 188ms (ActiveRecord: 27.9ms (44 queries, 6 cached) | GC: 13.7ms)
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2]
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] ActionView::Template::Error (undefined method 'link_local?' for nil)
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] Caused by: NoMethodError (undefined method 'link_local?' for nil)
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2]
web-1 | Information for: ActionView::Template::Error (undefined method 'link_local?' for nil):
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] 31: .flex
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] 32: = form.label :offset, class: 'block font-bold text-gray-700 dark:text-gray-200', for: "#{dom_id(address)}_offset" do
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] 33: = Address.human_attribute_name(:offset)
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] 34: .grow.mx-2= render AddressSpecialChipComponent.new(address: address)
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] 35: - if address.fixed? && allowed_to?(:update?, address)
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] 36: %button.text-white.bg-linear-to-r.from-cyan-500.to-blue-500.hover:bg-linear-to-bl.focus:ring-4.focus:outline-hidden.focus:ring-cyan-300.dark:focus:ring-cyan-800.font-medium.rounded-lg.text-sm.px-2.text-center{class: "py-0", type: "submit", name: "address[randomize_address]", form: dom_id(address, :secondary)}
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] 37: %i.fas.fa-dice
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2]
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/models/address.rb:128:in 'Address#special_range'
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/components/address_special_chip_component.rb:11:in 'AddressSpecialChipComponent#render?'
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/views/addresses/_address.html.haml:34
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/views/addresses/_address.html.haml:4
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/components/network_interface_form_component.html.haml:41:in 'NetworkInterfaceFormComponent#call'
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/views/virtual_machines/show.html.haml:23
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/components/sub_resource_section_component.html.haml:5:in 'SubResourceSectionComponent#call'
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/views/virtual_machines/show.html.haml:4
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2]
web-1 | Information for cause: NoMethodError (undefined method 'link_local?' for nil):
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2]
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/models/address.rb:128:in 'Address#special_range'
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/components/address_special_chip_component.rb:11:in 'AddressSpecialChipComponent#render?'
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/views/addresses/_address.html.haml:34
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/views/addresses/_address.html.haml:4
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/components/network_interface_form_component.html.haml:41:in 'NetworkInterfaceFormComponent#call'
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/views/virtual_machines/show.html.haml:23
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/components/sub_resource_section_component.html.haml:5:in 'SubResourceSectionComponent#call'
web-1 | [c832c279-859f-418c-b9e7-d5cf403ec4f2] app/views/virtual_machines/show.html.haml:4
Let's dive into this error and see what we can do to fix it!
Understanding the 500 Internal Server Error
First off, a 500 Internal Server Error is a general-purpose HTTP status code that indicates something went wrong on the server's side. It's like the server saying,