Title: Cannot access server &quot;Error establishing a database connection&quot;
Last modified: August 22, 2016

---

# Cannot access server "Error establishing a database connection"

 *  [mypi.forums](https://wordpress.org/support/users/mypiforums/)
 * (@mypiforums)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/cannot-access-server-error-establishing-a-database-connection/)
 * Hi There
    I have just installed Apache, PHP, MySQL and WordPress on my Raspberry
   Pi and setup a web server with these instructions: “[http://www.raspberrypi.org/learning/web-server-wordpress/worksheet.md&#8221](http://www.raspberrypi.org/learning/web-server-wordpress/worksheet.md&#8221);
   I was working on the website and changed the site url from my Pi’s IP address
   to my site URL([http://www.mypi.site.nz](http://www.mypi.site.nz)). Now when 
   I try to load the page from the Pi’s IP I get this error: “Error establishing
   a database connection”. Or from the URL: The server at [http://www.mypi.site.nz](http://www.mypi.site.nz)
   can’t be found, because the DNS lookup failed. DNS is the network service that
   translates a website’s name to its Internet address. This error is most often
   caused by having no connection to the Internet or a misconfigured network. It
   can also be caused by an unresponsive DNS server or a firewall preventing Google
   Chrome from accessing the network.
 * Any help greatly appreciated!!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/cannot-access-server-error-establishing-a-database-connection/#post-5259240)
 * > Incase anyone browsing the forums is unclear as to what is happening here, 
   > this guy is installing WordPress and a web server on a computer card which 
   > costs $40 or $50, and is the size of a pack of cigarettes. It has 512Mb RAM,
   > the ‘disk’ storage is an SD camera card. Add USB keyboard and mouse and HDMI
   > monitor, or run it over ssh or telnet.
   >  The operating system is various flavours
   > of Linux. All the software is FREE as in “FREE BEER”, even packages such as
   > mathematica
 * ANSWER:
    So you have successfully completed the instructions at: “[http://www.raspberrypi.org/learning/web-server-wordpress/worksheet.md&#8221](http://www.raspberrypi.org/learning/web-server-wordpress/worksheet.md&#8221);
 * Then you got creative and want to access your site by a name, as if it were using
   the DNS ?
    BUT the problmes are: – your rapi is on the local network, not the
   internet, I am not going into port forwarding and so on. – your name is not registered
   with the DNS, so will not resolve.
 * Instead you can short circuit the DNS and provide your own mapping using the “
   hosts” file.
 * So you have to do an extra step:
    – Add your IP address as the resolution of 
   your name at command prompt:
 *     ```
       sudo nano /etc/hosts
       add a lines:
       <your ip address> mypi.site.nz
       <your ip address> www.mypi.site.nz
       ```
   
 * save and exit
 * So now your /etc/hosts file will have some extra lines like:
 *     ```
       192.168.1.5 mypi.site.nz
       192.168.1.5 www.mypi.site.nz
       ```
   
 * – Now you should be able to access and login to your WordPress site from your
   browser at the expected address:
    [http://www.mypi.site.nz/](http://www.mypi.site.nz/)
 * – You can add the SAME lines to the hosts file on any computer on your LAN, then
   that computer will also be able to access your webserver. The location and name
   of the hosts file varies with operating system, the details are here:
    [http://en.wikipedia.org/wiki/Hosts_%28file%29](http://en.wikipedia.org/wiki/Hosts_%28file%29)
 * Please let me know how this works.
    I have a raspberrypi website here: [http://raspberrypi.education/](http://raspberrypi.education/)
   You can get my email address from my primary website referenced there.
 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/cannot-access-server-error-establishing-a-database-connection/#post-5259242)
 * You will also have to do some apache configuration:
    in /etc/apache2/sites-enabled
   edit the 001* file, clone a virtual block similar to:
 *     ```
       <VirtualHost *:80>
       DocumentRoot /var/www/public_html/wp
       ServerName mypi.site.nz
       </VirtualHost>
       ```
   
 * where “/var/www/public_html/wp” is the path from the root of your WordPress install
 * then restart apache2 handler:
    `sudo /etc/init.d/apache2 graceful`
 * As an added bonus, very useful for localhost installs:
 *     ```
       I was able to find a way to bypass the need for FTP credentials
       by adding the code below to my wp-config.php file
       	define('FS_METHOD', 'direct');
       ```
   
 *  [realvirginhumanhair](https://wordpress.org/support/users/realvirginhumanhair/)
 * (@realvirginhumanhair)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/cannot-access-server-error-establishing-a-database-connection/#post-5259377)
 * Please help me getting error message:
 * The server at site.realvirginhumanhair.com can’t be found, because the DNS lookup
   failed. DNS is the network service that translates a website’s name to its Internet
   address. This error is most often caused by having no connection to the Internet
   or a misconfigured network. It can also be caused by an unresponsive DNS server
   or a firewall preventing Google Chrome from accessing the network.
 * I had gotten a contractor to set it up for me and now its down it was directed
   from realvirginhumanhair.com I cancel from yahoo now I can’t pull it back up 
   please help.
 *  [realvirginhumanhair](https://wordpress.org/support/users/realvirginhumanhair/)
 * (@realvirginhumanhair)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/cannot-access-server-error-establishing-a-database-connection/#post-5259378)
 * site.realvirginhumanhair.store

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Cannot access server "Error establishing a database connection"’ is closed
to new replies.

## Tags

 * [apache](https://wordpress.org/support/topic-tag/apache/)
 * [url](https://wordpress.org/support/topic-tag/url/)

 * In: [Localhost Installs](https://wordpress.org/support/forum/localhost-installs/)
 * 4 replies
 * 3 participants
 * Last reply from: [realvirginhumanhair](https://wordpress.org/support/users/realvirginhumanhair/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/cannot-access-server-error-establishing-a-database-connection/#post-5259378)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
