question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Microservice port conflict at localhost

See original GitHub issue

Not sure it’s a bug or a ‘feature’ ERROR: for customergateway-postgresql Cannot start service customergateway-postgresql: b'driver failed programming external connectivity on endpoint docker_customergateway-postgresql_1 (7e89d2b724f17888bd1097ac2dd3acda2abcbaee5f0641a8361dca01da1d2495): Bind for 0.0.0.0:5432 failed: port is already allocated' An attempt to create a simple microservice app with the same DB type. It can be easily solved by setup DB ports for each microservice in JDL. Or even better do not use localhost at all! Use just hostnames like customergateway-postgresql:5432 instead of localhost:5432 I this case ports will never collide for services also it’s obvious by name ‘which-is-which’.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
pascalgrimaudcommented, May 4, 2020

I had a look at https://hub.docker.com/r/strm/dnsmasq/ and indeed, it could be a solution. But not sure it will work well for users with Windows.

Then, after thinking more about this feature request, I don’t think we will change something in our main generator-jhipster as the change is trivial and can be done in less than 30sec.

Adding a new option would be overkill, and we’ll have to do the same think for all database, all other services, and maintain it.

What can be done are:

  • a new module for using strm/dnsmasq -> feel free to code your own module and maintain it. I’ll be happy to test and play with it
  • add a new tips at https://www.jhipster.tech/tips/

For now, let’s close this.

2reactions
pascalgrimaudcommented, Apr 30, 2020

@mmuruev :

  • with dev profile, you shouldn’t have problem as your gateway uses h2disk and your microservice psql
  • you can have problem with prod profile as you need to start each psql (1 for gateway, 1 microservice)

To resolve this, IMO, the best would be:

  • create a separate project, use jhipster docker-compose, it will generate a big docker-compose file
  • clean all app, keep only database and services
  • expose port, differently for psql, 5432, then 5433, 5434 etc
  • then, change the default port of psql in appropriate microservice

I think it’s the best solution because when I start to dev, I launch this big docker-compose, instead of thinking about which services inside each microservices (consul, keycloak, kafka, psql etc etc)

Then, I don’t think we should include your feature in main generator, as we will need to do the same for all databases, store the config in yo-rc.json, add the option in JDL, maybe change all config in docker-compose, heroku, gcp, openshift, aws etc etc… Too much work for 1 or 2 minutes with sub generator docker-compose

Hope my solution will help you

Read more comments on GitHub >

github_iconTop Results From Across the Web

8080 port already taken issue when trying to redeploy project ...
You need to kill the port that localhost:8080 is running on. To do this, you need to do two commands in the terminal...
Read more >
Why you should never use fixed ports in your Testcontainers ...
Bind for 0.0.0.0:80 failed: port is already allocated. But there is more - localhost is the king! There was some ...
Read more >
TCP connect to localhost:8083 failed while installing ...
You're focusing on the port, but the issue seems to be that the service isn't starting in the first place. Most likely a...
Read more >
3 Ways to change Embedded Tomcat Server Port in Spring ...
Since by default, HTTP requests go to port 80, and if you have forwarded that request to 8080 and if your Spring Boot...
Read more >
Sharing routes and running multiple Java services in a single ...
Once again everything is working but under a single port this time. One Server Listening on Multiple Ports. Testing microservices, especially ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found