Reputation: 1942
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?
Upvotes: 10
Views: 15967
Reputation: 508
I was unable to connect to local server started in WSL 2 from Windows host machine, I tried everything, then rebooting Windows system magically fixed the problem.
Upvotes: 0
Reputation: 79
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
Upvotes: 1
Reputation: 397
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
Upvotes: 2
Reputation: 822
Try a different port:
rails s -p 3001
You might be behind a proxy as well. That could cause issues.
Upvotes: 2
Reputation: 1942
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.
Upvotes: 21