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.

Localhost Database inaccessible

See original GitHub issue

My DBT project accesses the database from localhost. The database itself is remote but the connection is tunnelled to localhost:5433 as it can only be accessed using a VPN from a particular host. Anyway, all this to say that if your ~/.dbt/profiles.yml host key has localhost as a value, then you get an error like the below after it tries and fails to access the database for some time:

DbtError: Error returned from dbt while executing method 'poll': Database Error
  could not connect to server: Connection refused
  	Is the server running on host "localhost" (127.0.0.1) and accepting
  	TCP/IP connections on port 5433?
  could not connect to server: Cannot assign requested address
  	Is the server running on host "localhost" (::1) and accepting
  	TCP/IP connections on port 5433?

I use a mac and I can bypass this by changing localhost to host.docker.internal if running Docker 18.03 or later but it would be nice if there was a better solution that didn’t require me changing this. Also not sure what non-mac users need to do in order to access localhost from within the container. This should be mentioned in your docs as it seems you are assuming everyone’s database is remote. My particular case is probably niche but many may be using a local database for dev purposes

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
owlascommented, Jun 28, 2021

@TuringLovesDeathMetal I’ve added a docs update to help users workaround this but the underlying issue isn’t solved.

you still have to modify your profiles.yml to get this to work, which isn’t ideal. I’m leaving “open” but removing from the dev board until we revisit it.

1reaction
owlascommented, Jun 18, 2021

No prob!

I’m going to add something to the docs for using host.docker.internal - I think that’s the best we have currently! Watch this space though

Read more comments on GitHub >

github_iconTop Results From Across the Web

Localhost Refused to Connect Error: 5 Confirmed Ways to Fix It
Localhost refused to connect error can be caused by an incorrectly configured port, insufficient permissions, or an inoperative web server.
Read more >
Database is not accessible on server but working well on ...
Now I recreated a blank database and then I executed the SQL script that I created for my database by navigating to "User...
Read more >
Database access denied after moving from localhost to live ...
Hello,. I've been trying to move a site from localhost to live environment. I have done everything step by step as Ryan suggested...
Read more >
How To Fix The "Error Establishing a Database Connection" in ...
1. Check Your Database Login Credentials · Database Name · MySQL database username · MySQL database password · MySQL hostname (server) · Check ......
Read more >
How to Fix the Error Establishing a Database Connection in ...
The 'Error establishing a database connection' issue can be caused by incorrect database information in your WordPress settings, corrupt ...
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