Fresh Strapi connection refused

System Information
  • Strapi Version: 4.3.4
  • Operating System: Ubuntu 20 (WSL Windows)
  • Database: Sqlite
  • Node Version: 16.15.0
  • NPM Version: 8.5.5
  • Yarn Version:

I was playing with strapi. Everything was working fine. Then Power cut, I hibernated my system then tried to load strapi again. Getting connection refused error in Edge and Firefox. I restarted system and same error. I installed a fresh new strapi and got same error. Tried to change the post from 1337 to 1338 and same error. Other nodejs apps are worknig fine with other ports. But strapi refusing connection.

curl -v http://localhost:1337 and 1338 giving proper result of strapi site. And it seems everything is okay.
But browser telling connection refused. Strange.
Tried 2-3 times with fresh strapi installs and different ports but same error.
Please help.

Welcome to the Strapi forums @Mayanktaker :wave:

What’s the output of the strapi server running when your trying to connect to it?

Hi. What do you mean by output ? Its showing connection refused in browser. And in vs code, nothing.

Here is curl -v output -


If you got to /admin does it ask you to register an account?

No. I am not getting any access. No admin, no root url access. Same error. Its strange and should not come because I was working on it before hibernation. I restarted the computer and tried with 2-3 new projects but same error. Where other apps working fine. Like DirectUs is working fine. So its not Nodejs install error I guess. But I am unable to identify the problem.

Just curious why is it port 1338 did you change it because default is 1337.

Also if you are using WSL then I’m going to guess that there lies the issue. It doesn’t proxy the ports it was a known issue in WSL earlier days (atleast when I used it few years ago).

So I would say if you are using WSL, I think you need to use the as the IP in the project, not localhost. This is about a year old btw

Fixing WSL2 localhost access issue - but as I said a known issue in WSL where ports and localhost is been a problem.

1 Like

I tried with different ports for cross check.
I don;t know how but the problem gone and Strapi working normally like nothing happened. Its very strange because I did nothing to fix the issue.
BTW, thank you for your time and quick help. I will check the links to understand the problem and solution for future encounter.

Thank you very much sir. :slight_smile:

1 Like

Most welcome.
I had experience with WSL first myself and the issues you been facing so that’s normally a issue to test.
But glad you got forward, normally a restart even works fine with WSL.

1 Like

Just for someone else encounter this problem, i solved it with the following command in CMD:
net stop winnat
start service in wsl
net start winnat

1 Like