FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Docker said 'Connection refused'. Localhost worked fine. The problem was one line.
NewsWeb Development

Docker said 'Connection refused'. Localhost worked fine. The problem was one line.

via Dev.to WebdevNico Reyes2d ago

Last week I containerized an app that was running fine locally. Deployed to Docker. Got connection refused errors immediately. Checked the port mapping. Correct. Checked the environment variables. Correct. Restarted the container probably 15 times. Logged into the container to debug. Ran curl localhost:3000 from inside. Worked perfectly. Ran the same curl from my host machine. Connection refused. The actual problem The app was binding to 127.0.0.1:3000 . Docker containers need to bind to 0.0.0.0 to accept connections from outside the container. Localhost only accepts connections from inside the container itself. Changed this: const express = require ( ' express ' ); const app = express (); // This only works inside the container app . listen ( 3000 , ' 127.0.0.1 ' , () => { console . log ( ' Server running on port 3000 ' ); }); To this: const express = require ( ' express ' ); const app = express (); // This accepts external connections app . listen ( 3000 , ' 0.0.0.0 ' , () => { conso

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
11 views

Related Articles

The HP OmniBook 5 Is a MacBook Neo Killer, and It's Only $500
News

The HP OmniBook 5 Is a MacBook Neo Killer, and It's Only $500

Wired • 2d ago

Trump defunding of NPR and PBS blocked by judge, but damage is already done
News

Trump defunding of NPR and PBS blocked by judge, but damage is already done

Ars Technica • 2d ago

Everything is iPhone now
News

Everything is iPhone now

The Verge • 2d ago

Terms & Conditions: Soundboks Giveaway
News

Terms & Conditions: Soundboks Giveaway

Wired • 2d ago

Our Favorite Budget Smartwatch is $69
News

Our Favorite Budget Smartwatch is $69

Wired • 2d ago

Discover More Articles