I'm working on a Rails project and for some reason, going to localhost:3000
showed me connection refused, not the site I'm developing. What happened?
Check your host file! By default, Rails only serves to 127.0.0.1. However, I had added additional entries for localhost
into my /etc/hosts file (the system takes the last one by default). Since this wasn't 127.0.0.1 (it was the IP of my machine on my private subnet of VM's), Rails wouldn't accept the connection. You could comment out the extra lines in your host file or start the development server with rails s -b 0.0.0.0
to allow any IP to connect to it.
i had the same problem, i tried to restart the server with a different port but the problem persisted
and i found the problem in the hosts file
so try first to connect to the server with ip adress of localhost
127.0.0.1:3000
This is because rails listens only on IPv6 by default, and 127.0.0.1 is IPv4:
$ netstat -ant | grep 3000
tcp6 0 0 ::1.3000 *.* LISTEN
Connect to ::1:3000
Try a different port:
rails s -p 3001
You might be behind a proxy as well. That could cause issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With