snipe-it
snipe-it copied to clipboard
Pre-flight for docker image isn't connecting to database
Please confirm you have done the following before posting your bug report:
- [x] I have enabled debug mode
- [x] I have read checked the Common Issues page
Describe the bug After setting up a Docker image of Snipe IT, I am getting the following on the pre-flight page. I checked all the .env files I can find but nothing is associated with that container ID. There's clearly a .env somewhere as I can access the URL. Any insight on this? Here is the error message:
D'oh! Looks like we can't connect to your database. Please update your database settings in your .env file. Your database says: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No address associated with hostname (SQL: select 2 + 2)
To Reproduce Steps to reproduce the behavior:
Install snipe-it and mysql in containers Configure app Reboot VM Expected behavior Snipe-it should work with all data from existing database.
Server (please complete the following information):
Snipe-IT Version: Latest docker image OS: Ubuntu 20.04 LTS Web Server: Apache PHP Version 7.2.24 Desktop (please complete the following information):
OS: MacOS Big Sur/Ubuntu 20.04 Browser Chrome, Firefox
Error Messages
D'oh! Looks like we can't connect to your database. Please update your database settings in your .env file. Your database says: SQLSTATE[HY000] [2002] Connection refused (SQL: select 2 + 2)
Additional context
Is this a fresh install or an upgrade? - Fresh What OS and web server you're running Snipe-IT on - Ubuntu 20.04, Apache 2.4 What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) - Docker
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
BREAKING CHANGE: This release requires PHP 7.2.5 or greater. ⚠️ Previous versions required PHP 7.2.0 or later, but a security upgrade to the Laravel framework forces the minimum requirement to PHP 7.2.5 in this release. Looks like starting from 05 February (release v5.1.1) version of PHP minium 7.2.5 is required
- did you try to update your php version?
Wanted to chime in and say I am running into the exact same error running the docker container. I'm using podman on a CentOS box rather than Docker, but identical preflight error to @rstaudmyer
I also tried connecting instead to an external mysql installation rather than a container as expected and am getting the same results.
@JakubPiasekAGH This is running from the docker container, which the latest version installs PHP 7.2.24
Edit: Connecting to an external DB works as expected. PEBCAK error. However using the internalDB still does not work. I think it may be down to a container dns issue. @rstaudmyer Can you get a shell into the snipe-it container and try to resolve the container name for the database? That may give a clue as to why it's not working. Though it's just a hunch.
Hi! has anyone found a solution? I am having the same problem here!
I mean, every time I spin up a Docker container and hook into a database and follow our instructions (which I wrote), it works for me. I can't replicate your error case here. I could also be too close to the metal here and could be missing something big; that's not only possible but is quite likely. But I'd need more details to work from.
I faced this issue, and resolved it by adding the following lines to my .env file :
MYSQL_PORT_3306_TCP_ADDR=snipeit_db
MYSQL_PORT_3306_TCP_PORT=3306
where snipeit_db is the container_name of my mariadb instance.
anyone get this fixed? I am running on CentOS Stream 8 using podman 4.2.0. I have tried @tperrindell 's fix and am still getting nowhere. I am able to ping the sql container from my snipe-it container, but still get this same error in the pre-flight check.
snipe-it containter label: v6.0.14 mysql container label: 5.6
anyone get this fixed? I am running on CentOS Stream 8 using podman 4.2.0. I have tried @tperrindell 's fix and am still getting nowhere. I am able to ping the sql container from my snipe-it container, but still get this same error in the pre-flight check.
snipe-it containter label: v6.0.14 mysql container label: 5.6
What if you try with mariadb instead?
Podman have a few peculiarities, I remember I faced something similar, even if I map the ports in my MySQL container. I think it has something to do with rootles containers... to be honest I didn't investigate enough the cause, just a solution. So I just used the network host
flag, which makes the container share the same network stack as the host. To run my database container I use a command similar to this:
podman run -it --rm -v <volume_route_to_persist_data>:Z --network host -e MYSQL_ROOT_PASSWORD=<root_passwd> -e MYSQL_DATABASE=<database_name> -e MYSQL_USER=<database_user> -e MYSQL_PASSWORD=<database_password> -d mysql:8.0.31
Where you can substitute for your own values everything between '<>' characters.
Unfortunately, the --network host
flag is not available to me (project constraint), but it's worth giving a shot when I have a chance. That being said, this project has been put to the side and I haven't even been able to test with mariadb, so I will have to check back with results.